[codex] Add reusable binding validator APIs#68
Draft
ostrowr wants to merge 2 commits into
Draft
Conversation
a17da60 to
47fddfa
Compare
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.
Summary
Make schema validation reusable across both the Python and JavaScript/WebAssembly bindings. The preferred end state is a parsed schema object that callers can reuse for repeated validation instead of reparsing schema text for every check, while Python callers can also validate already-materialized JSON-compatible values directly.
Details
validator_for(...) -> Validatorto the Python bindings.Validator.is_valid_json(...),Validator.is_valid_value(...), and a shortValidator.is_valid(...)alias for JSON-string validation.validator_for(...) -> Validatorto the JavaScript/WebAssembly bindings.Validator.is_valid(...)for repeated JSON-string validation in JS/Wasm consumers.Testing
just checkcargo test -p jsoncompat_py --all-features --lockedcargo test -p jsoncompat_wasm --all-features --lockedjust python-demowasm-pack build wasm --target web --releasevalidator_for(...)on JSON strings and native Python dictionaries; import the Wasm package and verifyvalidator_for(...).is_valid(...)on generated JSON.