FINERACT-2511: Return 400 for invalid dateFormat on client create/up…#5558
Open
oluexpert99 wants to merge 1 commit intoapache:developfrom
Open
FINERACT-2511: Return 400 for invalid dateFormat on client create/up…#5558oluexpert99 wants to merge 1 commit intoapache:developfrom
oluexpert99 wants to merge 1 commit intoapache:developfrom
Conversation
Contributor
|
@oluexpert99 sign your commit and make sure it is following the PR naming convention |
IOhacker
requested changes
Feb 28, 2026
Contributor
IOhacker
left a comment
There was a problem hiding this comment.
Kindly review my comments
…date
- Validate dateFormat in ClientDataValidator (create and update) so invalid
patterns (e.g. "02 February 2026") are rejected with 400 instead of 500.
- Add @DateFormat constraint and DateFormatValidator in fineract-validation;
ClientDataValidator uses DateFormatValidator.isValidPattern() for reuse.
- Annotate BusinessDateUpdateRequest.dateFormat with @DateFormat.
- Add ClientDataValidatorTest and DateFormatValidationTest;
3002148 to
bab5504
Compare
Contributor
Author
@IOhacker done |
adamsaghy
reviewed
Mar 2, 2026
Comment on lines
+28
to
+53
| @Override | ||
| public boolean isValid(String value, ConstraintValidatorContext context) { | ||
| if (StringUtils.isBlank(value)) { | ||
| return true; // blank is allowed; use @NotBlank if required | ||
| } | ||
| return isValidPattern(value); | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether the given string is a valid {@link DateTimeFormatter} pattern. Can be used by validators that are | ||
| * not annotation-based (e.g. when validating JSON commands that do not bind to a DTO). | ||
| * | ||
| * @param pattern | ||
| * the candidate pattern string | ||
| * @return {@code true} if the pattern is valid, {@code false} otherwise | ||
| */ | ||
| public static boolean isValidPattern(String pattern) { | ||
| if (StringUtils.isBlank(pattern)) { | ||
| return true; | ||
| } | ||
| try { | ||
| DateTimeFormatter.ofPattern(pattern); | ||
| return true; | ||
| } catch (IllegalArgumentException e) { | ||
| return false; | ||
| } |
Contributor
There was a problem hiding this comment.
Unnecessarily overcomplicated.
Below is doing the same:
try {
DateTimeFormatter.ofPattern(pattern);
return true;
} catch (IllegalArgumentException e) {
return false;
}
adamsaghy
requested changes
Mar 2, 2026
Contributor
adamsaghy
left a comment
There was a problem hiding this comment.
Please kindly check my concern.
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.
Description
Return 400 for invalid dateFormat on client create/update
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.