File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
main/java/org/everit/json/schema/loader
java/org/everit/json/schema/loader
resources/org/everit/jsonvalidator Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 9
9
import static org .everit .json .schema .loader .SpecificationVersion .DRAFT_4 ;
10
10
import static org .everit .json .schema .loader .SpecificationVersion .DRAFT_7 ;
11
11
12
+ import java .math .BigDecimal ;
12
13
import java .util .ArrayList ;
13
14
import java .util .Collection ;
14
15
import java .util .HashSet ;
@@ -148,7 +149,12 @@ NumberSchema.Builder buildNumberSchema() {
148
149
NumberSchema .Builder builder = NumberSchema .builder ();
149
150
maybe ("minimum" ).map (JsonValue ::requireNumber ).ifPresent (builder ::minimum );
150
151
maybe ("maximum" ).map (JsonValue ::requireNumber ).ifPresent (builder ::maximum );
151
- maybe ("multipleOf" ).map (JsonValue ::requireNumber ).ifPresent (builder ::multipleOf );
152
+ maybe ("multipleOf" ).map (JsonValue ::requireNumber ).ifPresent (multipleOf -> {
153
+ if (BigDecimal .ZERO .compareTo (BigDecimal .valueOf (multipleOf .doubleValue ())) == 0 ) {
154
+ throw new SchemaException (schemaJson .ls .locationOfCurrentObj (), "multipleOf should not be 0" );
155
+ }
156
+ builder .multipleOf (multipleOf );
157
+ });
152
158
maybe ("exclusiveMinimum" ).ifPresent (exclMin -> exclusiveLimitHandler .handleExclusiveMinimum (exclMin , builder ));
153
159
maybe ("exclusiveMaximum" ).ifPresent (exclMax -> exclusiveLimitHandler .handleExclusiveMaximum (exclMax , builder ));
154
160
return builder ;
Original file line number Diff line number Diff line change @@ -340,6 +340,14 @@ public void pointerResolutionQueryFailure() {
340
340
});
341
341
}
342
342
343
+ @ Test
344
+ void multipleOfShouldNotBeZero () {
345
+ SchemaException thrown = Assertions .assertThrows (SchemaException .class , () -> {
346
+ SchemaLoader .load (get ("multipleOfShouldNotBeZero" ));
347
+ });
348
+ assertEquals ("#: multipleOf should not be 0" , thrown .getMessage ());
349
+ }
350
+
343
351
@ Test @ Disabled
344
352
public void propsAroundRefExtendTheReferredSchema () {
345
353
ObjectSchema actual = (ObjectSchema ) SchemaLoader
Original file line number Diff line number Diff line change 730
730
}
731
731
}
732
732
}
733
+ },
734
+ "multipleOfShouldNotBeZero" : {
735
+ "multipleOf" : 0
733
736
}
734
737
}
You can’t perform that action at this time.
0 commit comments