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>
impl<'a> ValueValidator<'a>
Sourcepub fn pattern_errors(&self) -> &[(TypeId, PatternError)]
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.
Sourcepub fn validate(
&self,
ty: TypeId,
lexical: &str,
) -> Result<Value, ValidationError>
pub fn validate( &self, ty: TypeId, lexical: &str, ) -> Result<Value, ValidationError>
Validates a lexical form against a simple type, returning its value.
Sourcepub fn validate_with(
&self,
ty: TypeId,
lexical: &str,
ns: &dyn Namespaces,
) -> Result<Value, ValidationError>
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.
Sourcepub fn union_member(&self, ty: TypeId, lexical: &str) -> Option<TypeId>
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.
Sourcepub fn white_space(&self, ty: TypeId) -> Option<WhiteSpace>
pub fn white_space(&self, ty: TypeId) -> Option<WhiteSpace>
The effective whiteSpace of a simple type.
Sourcepub fn effective_facets(&self, ty: TypeId) -> Option<&FacetSet>
pub fn effective_facets(&self, ty: TypeId) -> Option<&FacetSet>
The facets in force on a simple type, composed up its whole chain.