pub struct ValidationContext<'a> {
pub schema: &'a SchemaDocument,
pub document: &'a EureDocument,
pub state: RefCell<ValidationState>,
pub union_tag_mode: UnionTagMode,
}Expand description
Validation context combining schema reference and mutable state.
Uses interior mutability (RefCell) to allow validators implementing
DocumentParser to record errors without requiring &mut self.
Fields§
§schema: &'a SchemaDocumentReference to the schema being validated against
document: &'a EureDocumentReference to the document being validated
state: RefCell<ValidationState>Mutable state (errors, warnings, path, holes)
union_tag_mode: UnionTagModeUnion tag mode for this validation context.
Implementations§
Source§impl<'a> ValidationContext<'a>
impl<'a> ValidationContext<'a>
Sourcepub fn new(document: &'a EureDocument, schema: &'a SchemaDocument) -> Self
pub fn new(document: &'a EureDocument, schema: &'a SchemaDocument) -> Self
Create a new validation context with default (Eure) mode.
Sourcepub fn with_mode(
document: &'a EureDocument,
schema: &'a SchemaDocument,
union_tag_mode: UnionTagMode,
) -> Self
pub fn with_mode( document: &'a EureDocument, schema: &'a SchemaDocument, union_tag_mode: UnionTagMode, ) -> Self
Create a new validation context with specified union tag mode.
Sourcepub fn with_state(
document: &'a EureDocument,
schema: &'a SchemaDocument,
state: ValidationState,
) -> Self
pub fn with_state( document: &'a EureDocument, schema: &'a SchemaDocument, state: ValidationState, ) -> Self
Create a context with existing state (for fork/merge).
Sourcepub fn with_state_and_mode(
document: &'a EureDocument,
schema: &'a SchemaDocument,
state: ValidationState,
union_tag_mode: UnionTagMode,
) -> Self
pub fn with_state_and_mode( document: &'a EureDocument, schema: &'a SchemaDocument, state: ValidationState, union_tag_mode: UnionTagMode, ) -> Self
Create a context with existing state and mode (for fork/merge).
Sourcepub fn record_error(&self, error: ValidationError)
pub fn record_error(&self, error: ValidationError)
Record an error.
Sourcepub fn record_warning(&self, warning: ValidationWarning)
pub fn record_warning(&self, warning: ValidationWarning)
Record a warning.
Sourcepub fn mark_has_holes(&self)
pub fn mark_has_holes(&self)
Mark that a hole was encountered.
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Check if any errors have been recorded.
Sourcepub fn error_count(&self) -> usize
pub fn error_count(&self) -> usize
Get the current error count.
Sourcepub fn push_path_ident(&self, ident: Identifier)
pub fn push_path_ident(&self, ident: Identifier)
Push an identifier to the path.
Sourcepub fn push_path_key(&self, key: ObjectKey)
pub fn push_path_key(&self, key: ObjectKey)
Push a key to the path.
Sourcepub fn push_path_index(&self, index: usize)
pub fn push_path_index(&self, index: usize)
Push an array index to the path.
Sourcepub fn push_path_tuple_index(&self, index: u8)
pub fn push_path_tuple_index(&self, index: u8)
Push a tuple index to the path.
Sourcepub fn push_path_extension(&self, ident: Identifier)
pub fn push_path_extension(&self, ident: Identifier)
Push an extension to the path.
Sourcepub fn fork_state(&self) -> ValidationState
pub fn fork_state(&self) -> ValidationState
Fork for trial validation (returns forked state).
Sourcepub fn merge_state(&self, other: ValidationState)
pub fn merge_state(&self, other: ValidationState)
Merge forked state back.
Sourcepub fn resolve_schema_content(
&self,
schema_id: SchemaNodeId,
) -> &SchemaNodeContent
pub fn resolve_schema_content( &self, schema_id: SchemaNodeId, ) -> &SchemaNodeContent
Resolve type references to get the actual schema content.
Sourcepub fn parse_context(&self, node_id: NodeId) -> ParseContext<'a>
pub fn parse_context(&self, node_id: NodeId) -> ParseContext<'a>
Create a ParseContext for the given node with this context’s union tag mode.
Sourcepub fn record_variant_errors(
&self,
variant_name: String,
errors: Vec<ValidationError>,
)
pub fn record_variant_errors( &self, variant_name: String, errors: Vec<ValidationError>, )
Record variant attempt errors during union validation.
Sourcepub fn take_variant_errors(&self) -> Vec<(String, Vec<ValidationError>)>
pub fn take_variant_errors(&self) -> Vec<(String, Vec<ValidationError>)>
Take collected variant errors.
Sourcepub fn clear_variant_errors(&self)
pub fn clear_variant_errors(&self)
Clear variant errors.
Sourcepub fn finish(self) -> ValidationOutput
pub fn finish(self) -> ValidationOutput
Consume context and produce final output.