Replace @NotNull with @NotBlank on String fields in loan DTOs - #70
Open
Tanjim003 wants to merge 7 commits into
Open
Replace @NotNull with @NotBlank on String fields in loan DTOs#70Tanjim003 wants to merge 7 commits into
Tanjim003 wants to merge 7 commits into
Conversation
|
Hi @Tanjim003 , Tested on branch 7b7a56d locally. LoanCancellationControllerTest — 15 tests, 0 failures Correct annotation — @notblank handles null + empty + whitespace for string fields. Consistent with PR #69. Note: MifosWorkflowApplicationTests.contextLoads failure is pre-existing (baseUrl == null for Fineract config) — unrelated to this PR. Approving. |
Contributor
|
BLOCKED CLA NOT SIGNED |
|
CLA Block Removed |
Contributor
|
FYI: see #74 for the new direction/architecture of this project |
fix: Fineract SDK dependencies
chore: Update security note
@NotNull on String fields only prevents null values but allows empty strings to pass validation silently. This caused blank loanType and cancellationReason values to bypass local validation and reach the workflow service with meaningless empty strings. - LoanCreateRequestDTO: @NotNull → @notblank on loanType field - LoanCancellationRequestDTO: @NotNull → @notblank on cancellationReason field - Added descriptive validation messages to both fields Part of the broader validation improvement across all workflow DTOs.
Tanjim003
force-pushed
the
fix/replace-notnull-with-notblank-in-loan-dtos
branch
from
August 14, 2026 20:04
7b7a56d to
979d161
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace @NotNull with @notblank on String fields in LoanCreateRequestDTO
and LoanCancellationRequestDTO.
Problem
@NotNull on String fields only blocks null values — it allows empty
strings "" and whitespace " " to pass validation silently. This meant:
workflow service with a meaningless empty loan type
with no meaningful reason provided
This is the same issue fixed in PR #69 for ClientCreateRequestDTO.
Changes
Before / After
Before: POST /api/v1/workflow/loan-origination/start with empty loanType
→ Request passed validation and reached workflow service
After: POST /api/v1/workflow/loan-origination/start with empty loanType
→ 400 Bad Request
{
"title": "VALIDATION_FAILED",
"status": 400,
"fieldErrors": {
"loanType": "Loan type is required"
}
}
Same behaviour confirmed for cancellationReason in loan cancellation endpoint.
Test Results
LoanCancellationControllerTest — 15 tests, 0 failures
LoanOriginationControllerTest — 10 tests, 0 failures
All 25 tests pass with no failures.
Related
Continues validation improvements from PR #69 which fixed
ClientCreateRequestDTO and added spring-boot-starter-validation.