ValidationContext

Struct ValidationContext 

Source
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 SchemaDocument

Reference to the schema being validated against

§document: &'a EureDocument

Reference to the document being validated

§state: RefCell<ValidationState>

Mutable state (errors, warnings, path, holes)

§union_tag_mode: UnionTagMode

Union tag mode for this validation context.

Implementations§

Source§

impl<'a> ValidationContext<'a>

Source

pub fn new(document: &'a EureDocument, schema: &'a SchemaDocument) -> Self

Create a new validation context with default (Eure) mode.

Source

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.

Source

pub fn with_state( document: &'a EureDocument, schema: &'a SchemaDocument, state: ValidationState, ) -> Self

Create a context with existing state (for fork/merge).

Source

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).

Source

pub fn record_error(&self, error: ValidationError)

Record an error.

Source

pub fn record_warning(&self, warning: ValidationWarning)

Record a warning.

Source

pub fn mark_has_holes(&self)

Mark that a hole was encountered.

Source

pub fn has_errors(&self) -> bool

Check if any errors have been recorded.

Source

pub fn error_count(&self) -> usize

Get the current error count.

Source

pub fn path(&self) -> EurePath

Get a clone of the current path.

Source

pub fn push_path_ident(&self, ident: Identifier)

Push an identifier to the path.

Source

pub fn push_path_key(&self, key: ObjectKey)

Push a key to the path.

Source

pub fn push_path_index(&self, index: usize)

Push an array index to the path.

Source

pub fn push_path_tuple_index(&self, index: u8)

Push a tuple index to the path.

Source

pub fn push_path_extension(&self, ident: Identifier)

Push an extension to the path.

Source

pub fn pop_path(&self)

Pop the last segment from the path.

Source

pub fn fork_state(&self) -> ValidationState

Fork for trial validation (returns forked state).

Source

pub fn merge_state(&self, other: ValidationState)

Merge forked state back.

Source

pub fn resolve_schema_content( &self, schema_id: SchemaNodeId, ) -> &SchemaNodeContent

Resolve type references to get the actual schema content.

Source

pub fn parse_context(&self, node_id: NodeId) -> ParseContext<'a>

Create a ParseContext for the given node with this context’s union tag mode.

Source

pub fn record_variant_errors( &self, variant_name: String, errors: Vec<ValidationError>, )

Record variant attempt errors during union validation.

Source

pub fn take_variant_errors(&self) -> Vec<(String, Vec<ValidationError>)>

Take collected variant errors.

Source

pub fn clear_variant_errors(&self)

Clear variant errors.

Source

pub fn finish(self) -> ValidationOutput

Consume context and produce final output.

Auto Trait Implementations§

§

impl<'a> !Freeze for ValidationContext<'a>

§

impl<'a> !RefUnwindSafe for ValidationContext<'a>

§

impl<'a> Send for ValidationContext<'a>

§

impl<'a> !Sync for ValidationContext<'a>

§

impl<'a> Unpin for ValidationContext<'a>

§

impl<'a> UnwindSafe for ValidationContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.