feat: inline validators in standalone output#854
Open
RelevantShannon wants to merge 1 commit into
Open
Conversation
Member
|
This is awesome. Why is it still a draft? |
RelevantShannon
marked this pull request as ready for review
July 20, 2026 03:39
Author
Ah sorry, it was a Friday, and I wasn't sure if it was ready yet. I think it is :D |
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.
Add an opt-in mode that embeds Ajv's generated validators into fast-json-stringify standalone output.
Standalone mode currently restores an Ajv-backed validator from serialized schema state. Schemas using
anyOf,oneOf, orif/then/elsetherefore still compile their branch validators at runtime. The newinlineValidatorsoption asks Ajv's standalone compiler for the exact fragment validators used by the generated serializer and includes them in the same output module.The inline path is intentionally scoped:
inlineValidatorsis trueThis also makes the internal
fjs_typekeyword code-generating so Date and othertoJSONvalues remain compatible with Ajv standalone output. External schema refs and built-in formats are included through Ajv's normal standalone dependency handling.The output remains one generated module, but still uses fast-json-stringify's standalone serializer dependency and may reference small Ajv runtime helpers when required by the generated validation code.
Verification:
npm test passed locally with 479 tests and 0 failures.