Improve format - #285
Merged
Merged
Improve format#285
Conversation
Error handlers, getErrors, and getSuccesses now take an ErrorHandlerContext instead of the AST. The context has the AST and gives a place for information about how the instance was validated, which needs to reach handlers through nested descriptions, including ones built by third-party applicator handlers. describeEach and describeScope take the context too because they describe subschemas. Helpers that only read the schema still take the AST. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whether 'format' is an assertion depends on how the validator is configured, so success and negated messages always said that 'format' only applies if formats are validated. Now the error handler context says whether a 'format' keyword was validated. The format handler uses plain messages when it was, says nothing when it's only an annotation, and keeps the hedged messages when it's not known. jsonSchemaErrors takes an isFormatAsserted option because only the caller knows how their validator was configured. The JSE output format works it out from @hyperjump/json-schema's shouldValidateFormat setting and each dialect's default. Formats that aren't supported always pass, so they aren't validated either. This also adds support for the v1 'format' keyword. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whether
formatbehaves as an assertion depends on how the validator is configured, so success and negated messages always said thatformatonly applies if formats are validated. Now the error handler context says whether aformatkeyword was validated. Theformathandler uses plain messages when it was, says nothing when it's only an annotation, and keeps the hedged messages when it's not known.jsonSchemaErrorstakes anisFormatAssertedoption because only the caller knows how their validator was configured. TheJSEoutput format works it out from@hyperjump/json-schema'sshouldValidateFormatsetting and each dialect's default. Formats that aren't supported always pass, so they aren't validated either.This also adds support for the v1
formatkeyword.