Skip to content

Commit 912ee75

Browse files
authored
Merge pull request #343 from oguzhanunlu/numeric-validation
Improve type validation of numeric values
2 parents 56c1625 + f1c56df commit 912ee75

17 files changed

+90
-23
lines changed

src/main/java/com/networknt/schema/DateTimeValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
5151

5252
Set<ValidationMessage> errors = new LinkedHashSet<ValidationMessage>();
5353

54-
JsonType nodeType = TypeFactory.getValueNodeType(node);
54+
JsonType nodeType = TypeFactory.getValueNodeType(node, super.config);
5555
if (nodeType != JsonType.STRING) {
5656
return errors;
5757
}

src/main/java/com/networknt/schema/EnumValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
9696
* @param node JsonNode to check
9797
*/
9898
private boolean isTypeLooseContainsInEnum(JsonNode node) {
99-
if (TypeFactory.getValueNodeType(node) == JsonType.STRING) {
99+
if (TypeFactory.getValueNodeType(node, super.config) == JsonType.STRING) {
100100
String nodeText = node.textValue();
101101
for (JsonNode n : nodes) {
102102
String value = n.asText();

src/main/java/com/networknt/schema/ExclusiveMaximumValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public String thresholdValue() {
9999
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
100100
debug(logger, node, rootNode, at);
101101

102-
if (!TypeValidator.isNumber(node, config.isTypeLoose())) {
102+
if (!TypeValidator.isNumber(node, super.config)) {
103103
// maximum only applies to numbers
104104
return Collections.emptySet();
105105
}

src/main/java/com/networknt/schema/ExclusiveMinimumValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public String thresholdValue() {
106106
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
107107
debug(logger, node, rootNode, at);
108108

109-
if (!TypeValidator.isNumber(node, config.isTypeLoose())) {
109+
if (!TypeValidator.isNumber(node, super.config)) {
110110
// minimum only applies to numbers
111111
return Collections.emptySet();
112112
}

src/main/java/com/networknt/schema/FormatValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
4141

4242
Set<ValidationMessage> errors = new LinkedHashSet<ValidationMessage>();
4343

44-
JsonType nodeType = TypeFactory.getValueNodeType(node);
44+
JsonType nodeType = TypeFactory.getValueNodeType(node, super.config);
4545
if (nodeType != JsonType.STRING) {
4646
return errors;
4747
}

src/main/java/com/networknt/schema/MaxLengthValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public MaxLengthValidator(String schemaPath, JsonNode schemaNode, JsonSchema par
4141
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
4242
debug(logger, node, rootNode, at);
4343

44-
JsonType nodeType = TypeFactory.getValueNodeType(node);
44+
JsonType nodeType = TypeFactory.getValueNodeType(node, super.config);
4545
if (nodeType != JsonType.STRING) {
4646
// ignore no-string typs
4747
return Collections.emptySet();

src/main/java/com/networknt/schema/MaximumValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public String thresholdValue() {
108108
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
109109
debug(logger, node, rootNode, at);
110110

111-
if (!TypeValidator.isNumber(node, config.isTypeLoose())) {
111+
if (!TypeValidator.isNumber(node, super.config)) {
112112
// maximum only applies to numbers
113113
return Collections.emptySet();
114114
}

src/main/java/com/networknt/schema/MinLengthValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public MinLengthValidator(String schemaPath, JsonNode schemaNode, JsonSchema par
4141
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
4242
debug(logger, node, rootNode, at);
4343

44-
JsonType nodeType = TypeFactory.getValueNodeType(node);
44+
JsonType nodeType = TypeFactory.getValueNodeType(node, super.config);
4545
if (nodeType != JsonType.STRING) {
4646
// ignore non-string types
4747
return Collections.emptySet();

src/main/java/com/networknt/schema/MinimumValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public String thresholdValue() {
114114
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
115115
debug(logger, node, rootNode, at);
116116

117-
if (!TypeValidator.isNumber(node, config.isTypeLoose())) {
117+
if (!TypeValidator.isNumber(node, super.config)) {
118118
// minimum only applies to numbers
119119
return Collections.emptySet();
120120
}

src/main/java/com/networknt/schema/PatternValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private boolean matches(String value) {
9494
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
9595
debug(logger, node, rootNode, at);
9696

97-
JsonType nodeType = TypeFactory.getValueNodeType(node);
97+
JsonType nodeType = TypeFactory.getValueNodeType(node, super.config);
9898
if (nodeType != JsonType.STRING) {
9999
return Collections.emptySet();
100100
}
@@ -151,7 +151,7 @@ private boolean matches(String value) {
151151
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
152152
debug(logger, node, rootNode, at);
153153

154-
JsonType nodeType = TypeFactory.getValueNodeType(node);
154+
JsonType nodeType = TypeFactory.getValueNodeType(node, super.config);
155155
if (nodeType != JsonType.STRING) {
156156
return Collections.emptySet();
157157
}

0 commit comments

Comments
 (0)