Skip to main content

ValueValidator

Struct ValueValidator 

Source
pub struct ValueValidator<'a> { /* private fields */ }
Expand description

Validates values against a compiled schema’s simple types.

Cheap to make: the facets and patterns it checks against were prepared once, when the schema was compiled, and are shared by every validator.

Implementations§

Source§

impl<'a> ValueValidator<'a>

Source

pub fn new(schemas: &'a Schemas) -> Self

A validator over every simple type in the schema.

Source

pub fn pattern_errors(&self) -> &[(TypeId, PatternError)]

Patterns in the schema that could not be compiled, each with the type that declared it.

Non-empty means some type is more permissive than it declares. The same failures are diagnostics when the schema is compiled, so this is for a caller holding a Schemas whose diagnostics are gone — one read back from a cache, say.

Source

pub fn validate( &self, ty: TypeId, lexical: &str, ) -> Result<Value, ValidationError>

Validates a lexical form against a simple type, returning its value.

Source

pub fn validate_with( &self, ty: TypeId, lexical: &str, ns: &dyn Namespaces, ) -> Result<Value, ValidationError>

Self::validate, with the namespace bindings in scope where the value was written.

xs:QName and xs:NOTATION are the only datatypes whose value is not a function of the lexical form alone: a:x names whatever a is bound to there. Without bindings an unprefixed name is still a value — it is in no namespace — and a prefixed one cannot be resolved.

The XSD version is not a parameter here the way it is on crate::values::parse_with: the schema this validator was built from already settled which language applies.

Source

pub fn union_member(&self, ty: TypeId, lexical: &str) -> Option<TypeId>

Which member type of a union accepted the value.

Useful because a union’s actual type is part of the PSVI, not merely whether the value was valid.

Source

pub fn white_space(&self, ty: TypeId) -> Option<WhiteSpace>

The effective whiteSpace of a simple type.

Source

pub fn effective_facets(&self, ty: TypeId) -> Option<&FacetSet>

The facets in force on a simple type, composed up its whole chain.

Source

pub fn schemas(&self) -> &'a Schemas

Trait Implementations§

Source§

impl<'a> Debug for ValueValidator<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ValueValidator<'a>

§

impl<'a> RefUnwindSafe for ValueValidator<'a>

§

impl<'a> Send for ValueValidator<'a>

§

impl<'a> Sync for ValueValidator<'a>

§

impl<'a> Unpin for ValueValidator<'a>

§

impl<'a> UnsafeUnpin for ValueValidator<'a>

§

impl<'a> UnwindSafe for ValueValidator<'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.
§

impl<T> Ungil for T
where T: Send,