Skip to content

Add document schema validator to eure-schema crate#21

Merged
ryo33 merged 10 commits intomainfrom
claude/add-schema-validator-01MD63uf8xvenkTdMmFjD5Qz
Nov 30, 2025
Merged

Add document schema validator to eure-schema crate#21
ryo33 merged 10 commits intomainfrom
claude/add-schema-validator-01MD63uf8xvenkTdMmFjD5Qz

Conversation

@ryo33
Copy link
Member

@ryo33 ryo33 commented Nov 30, 2025

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

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
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.
@ryo33 ryo33 merged commit 0271149 into main Nov 30, 2025
1 check passed
@ryo33 ryo33 deleted the claude/add-schema-validator-01MD63uf8xvenkTdMmFjD5Qz branch January 5, 2026 04:36
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.

2 participants