Skip to content

Fix minimum maximum validators with type array#1227

Merged
stevehu merged 1 commit intonetworknt:masterfrom
justin-tay:gh1226
Jan 21, 2026
Merged

Fix minimum maximum validators with type array#1227
stevehu merged 1 commit intonetworknt:masterfrom
justin-tay:gh1226

Conversation

@justin-tay
Copy link
Collaborator

Closes #1226

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where minimum, maximum, exclusiveMinimum, and exclusiveMaximum validators did not work correctly when the schema's type field was an array (e.g., ["null", "integer"]). The fix refactors the type checking logic from using getNodeFieldType() to a new hasType(String type) method that can handle both string and array type values.

Changes:

  • Refactored getNodeFieldType() method to hasType(String type) in BaseKeywordValidator to support array type checking
  • Updated four validator classes to use the new hasType() method instead of getNodeFieldType()
  • Added comprehensive test coverage for all four validators with array type scenarios

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java Replaced getNodeFieldType() with hasType() method to support array type checking
src/main/java/com/networknt/schema/keyword/MinimumValidator.java Updated to use hasType() instead of getNodeFieldType()
src/main/java/com/networknt/schema/keyword/MaximumValidator.java Updated to use hasType() instead of getNodeFieldType()
src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java Updated to use hasType() instead of getNodeFieldType()
src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java Updated to use hasType() instead of getNodeFieldType()
src/test/java/com/networknt/schema/MinimumValidatorTest.java Added test for minimum validator with array type
src/test/java/com/networknt/schema/MaximumValidatorTest.java Added test for maximum validator with array type
src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java Added test for exclusiveMinimum validator with array type
src/test/java/com/networknt/schema/ExclusiveMaximumValidatorTest.java New test file for exclusiveMaximum validator with array type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stevehu stevehu merged commit 43cbcf7 into networknt:master Jan 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JsonNodeException on nullable integer with minimum

2 participants