Skip to content

[codex] Add reusable binding validator APIs#68

Draft
ostrowr wants to merge 2 commits into
mainfrom
codex/remove-is-valid-for-0-4
Draft

[codex] Add reusable binding validator APIs#68
ostrowr wants to merge 2 commits into
mainfrom
codex/remove-is-valid-for-0-4

Conversation

@ostrowr
Copy link
Copy Markdown
Owner

@ostrowr ostrowr commented Apr 6, 2026

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

  • Add validator_for(...) -> Validator to the Python bindings.
  • Expose Validator.is_valid_json(...), Validator.is_valid_value(...), and a short Validator.is_valid(...) alias for JSON-string validation.
  • Reject non-finite floats, non-string object keys, and integers outside the supported JSON number range before schema validation.
  • Add validator_for(...) -> Validator to the JavaScript/WebAssembly bindings.
  • Expose Validator.is_valid(...) for repeated JSON-string validation in JS/Wasm consumers.
  • Update the Python typing stub, both binding READMEs, and the Python/Wasm demos.

Testing

  • just check
  • cargo test -p jsoncompat_py --all-features --locked
  • cargo test -p jsoncompat_wasm --all-features --locked
  • just python-demo
  • wasm-pack build wasm --target web --release
  • Suggested manual check: install the built Python wheel and verify validator_for(...) on JSON strings and native Python dictionaries; import the Wasm package and verify validator_for(...).is_valid(...) on generated JSON.

@ostrowr ostrowr changed the title [codex] Remove one-shot Python is_valid for 0.4.0 [codex] Add reusable Python value validation API May 19, 2026
@ostrowr ostrowr changed the base branch from codex/stamp-dataclasses-codegen to main May 19, 2026 06:11
@ostrowr ostrowr force-pushed the codex/remove-is-valid-for-0-4 branch from a17da60 to 47fddfa Compare May 19, 2026 06:11
@ostrowr ostrowr changed the title [codex] Add reusable Python value validation API [codex] Add reusable binding validator APIs May 19, 2026
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.

1 participant