Skip to content

Replace @NotNull with @NotBlank on String fields in loan DTOs - #70

Open
Tanjim003 wants to merge 7 commits into
openMF:mainfrom
Tanjim003:fix/replace-notnull-with-notblank-in-loan-dtos
Open

Replace @NotNull with @NotBlank on String fields in loan DTOs#70
Tanjim003 wants to merge 7 commits into
openMF:mainfrom
Tanjim003:fix/replace-notnull-with-notblank-in-loan-dtos

Conversation

@Tanjim003

Copy link
Copy Markdown
Contributor

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:

  • LoanCreateRequestDTO.loanType: "" passed validation and reached the
    workflow service with a meaningless empty loan type
  • LoanCancellationRequestDTO.cancellationReason: "" passed validation
    with no meaningful reason provided

This is the same issue fixed in PR #69 for ClientCreateRequestDTO.

Changes

  • LoanCreateRequestDTO: @NotNull@notblank on loanType field
  • LoanCancellationRequestDTO: @NotNull@notblank on cancellationReason field
  • Added descriptive validation messages to both fields

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.

@saksham869

Copy link
Copy Markdown

Hi @Tanjim003 , Tested on branch 7b7a56d locally.

LoanCancellationControllerTest — 15 tests, 0 failures
LoanOriginationControllerTest — 10 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.

@DavidH-1

DavidH-1 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

BLOCKED CLA NOT SIGNED

@DavidMifosA

Copy link
Copy Markdown

CLA Block Removed

@vidakovic

Copy link
Copy Markdown
Contributor

FYI: see #74 for the new direction/architecture of this project

vidakovic and others added 6 commits August 13, 2026 10:59
@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
Tanjim003 force-pushed the fix/replace-notnull-with-notblank-in-loan-dtos branch from 7b7a56d to 979d161 Compare August 14, 2026 20:04
@Tanjim003
Tanjim003 requested a review from a team August 14, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants