Add document schema validator to eure-schema crate#21
Merged
Conversation
Implements validation of Eure values against schema definitions with: - Primitive type validation (text, integer, float, boolean, null, any) - Container type validation (array, map, record, tuple) - Union type validation with oneOf semantics (external, internal, adjacent, untagged) - Type reference resolution - Constraint validation (length, range, pattern, multiple-of, unique) - Hole value support (valid but incomplete) - Comprehensive error reporting with path information
- Add schema and schema_errors fields to Case struct - Add SchemaValidation and SchemaErrorValidation scenarios - Implement document_to_value helper for converting EureDocument to Value - Create test case files for schema validation: - cases/schema/valid-primitives.eure (passing test) - cases/schema/errors/type-mismatch.eure (error test)
- valid-nested-record.eure: Test nested record validation - valid-array.eure: Test array type validation - valid-type-reference.eure: Test type reference resolution - errors/missing-required-field.eure: Test missing field error - errors/array-item-type-mismatch.eure: Test array element type error
…idator-01MD63uf8xvenkTdMmFjD5Qz
The validator now directly validates EureDocument nodes, which preserves extension information needed for: - Union type discrimination via $variant extension - Schema-defined extension types validation Key changes: - Changed validate() signature to take &EureDocument instead of &Value - Added validate_node() for validating specific nodes - Added validate_value() convenience wrapper that converts Value to document - Updated test-suite to use new EureDocument-based API - Removed unused document_to_value helper from test-suite
- Use let-chains (if let Some(x) = y && condition) for collapsible if - Replace map_or with is_some_and for Option checks - Apply rustfmt formatting
Fix struct initialization in test-suite/src/case.rs tests to include the schema and schema_errors fields that were added to PreprocessedCase.
The old schemas/*.eure test files use a different schema syntax (.integer, .string etc.) that isn't valid Eure. Renamed their schema field to type_schema to avoid conflicting with schema validation which expects valid Eure schema documents.
Changed .integer/.string to `integer`/`text` etc. per the schema spec.
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.
Implements validation of Eure values against schema definitions with: