Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-6030 : The allergy field in the Allergy UI should validate the input string #4534

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TRUNK-6030
TRUNK-6030: validate the input string
  • Loading branch information
subhamkumarr committed Jan 17, 2024
commit 78742afe9fa4dc2ff7423e1cd0632244bbfc6c68
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void validate(Object target, Errors errors) {
}

if (StringUtils.isNumeric(allergen.getNonCodedAllergen())) {
errors.rejectValue("allergen", "error.allergyapi.allergy.Allergen.cannotContainNumeric");
errors.rejectValue("allergen", ".allergyapi.allergy.Allergen.cannotContainNumeric");
}

if (allergy.getAllergyId() == null && allergy.getPatient() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ public void validate_shouldRejectNumericAllergenValue() {
Errors errors = new BindException(allergy,"allergy");
validator.validate(allergy, errors);
assertTrue(errors.hasErrors());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually validate the error message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibacher Sir, please check I made the changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibacher could you please review my PR.

assertThat(errors.getFieldError("allergen").getCode(), is("Allergen cannot be numeric value"));
}
assertTrue(errors.getAllErrors().stream()
.anyMatch(error -> "allergyapi.allergy.Allergen.cannotContainNumeric".equals(error.getCode()))); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent here should be with tabs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the curly brace belongs on a new line. Please ensure you're following the Java Conventions and see this to setup your IDE (basically, whatever mechanism will take an Eclipse formatting configuration).

}
Loading