networknt / json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Apache License 2.0
822 stars 323 forks source link

Refactor format validation #958

Closed justin-tay closed 7 months ago

justin-tay commented 7 months ago

Closes #957, closes #848

This shouldn't contain any breaking changes, instead some methods are deprecated with some workarounds to cater to the old behavior.

This refactors the format validation to do the following

Custom Format https://json-schema.org/draft/2020-12/json-schema-validation#name-foreword

All format attributes defined in this section apply to strings, 
but a format attribute can be specified to apply to any instance types defined in the data 
model defined in the [core JSON Schema.]

Unknown Format https://json-schema.org/draft/2020-12/json-schema-validation#name-custom-format-attributes

When the Format-Assertion vocabulary is specified, implementations MUST fail upon encountering unknown formats.

Note that having the vocab is different from enabling assertions as an option.

codecov-commenter commented 7 months ago

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (32356e9) 79.01% compared to head (e2ac373) 78.79%.

Files Patch % Lines
...ain/java/com/networknt/schema/FormatValidator.java 69.23% 5 Missing and 3 partials :warning:
...main/java/com/networknt/schema/JsonMetaSchema.java 68.42% 5 Missing and 1 partial :warning:
...va/com/networknt/schema/format/DateTimeFormat.java 85.71% 1 Missing and 1 partial :warning:
...ava/com/networknt/schema/format/PatternFormat.java 84.61% 0 Missing and 2 partials :warning:
src/main/java/com/networknt/schema/Format.java 93.33% 1 Missing :warning:
...va/com/networknt/schema/format/DurationFormat.java 85.71% 0 Missing and 1 partial :warning:
...com/networknt/schema/format/IdnHostnameFormat.java 80.00% 0 Missing and 1 partial :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #958 +/- ## ============================================ - Coverage 79.01% 78.79% -0.23% - Complexity 1726 1767 +41 ============================================ Files 158 160 +2 Lines 5753 5797 +44 Branches 1087 1080 -7 ============================================ + Hits 4546 4568 +22 - Misses 809 825 +16 - Partials 398 404 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.