Skip to content

Commit

Permalink
Releasing new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto-Gentili committed Oct 24, 2023
1 parent 31892bd commit bb34bb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/test/java/org/burningwave/json/ValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ class ValidatorTest extends BaseTest {
void validateTestOne() {
testThrow(() -> {
facade.validator().registerCheck(
//Check
//Checking whether a value in any field marked as required (e.g.: @JsonProperty(value = "answer", required = true)) is null
Check.forAll().checkMandatory(),
Check.forAllStringValues().execute(validationContext -> {

//Checking whether a string value in any field is empty
Check.forAllStringValues().execute(pathValidationContext -> {
if (pathValidationContext.getValue() != null && pathValidationContext.getValue().trim().equals("")) {
pathValidationContext.rejectValue("IS_EMPTY", "is empty");
}
})
);

Expand All @@ -25,7 +28,6 @@ void validateTestOne() {
ObjectHandlerTest.class.getClassLoader().getResourceAsStream("quiz-to-be-validated.json"),
Root.class
);
ObjectHandler objectHandler = facade.newObjectHandler(jsonObject);
Collection<Throwable> exceptions = facade.validator().validate(Validation.Config.forJsonObject(jsonObject).withCompleteValidation());
for (Throwable exc : exceptions) {
System.err.println(exc.getMessage());
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/quiz-to-be-validated.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"1",
"2",
"3",
"4"
""
],
"answer": "4"
}
Expand Down

0 comments on commit bb34bb0

Please sign in to comment.