Skip to main content

value_error_constraint_code

Function value_error_constraint_code 

Source
pub fn value_error_constraint_code(err: &ValidationError) -> &'static str
Expand description

Map a TypeValidationError variant to its default cvc-* constraint code

Returns cvc-datatype-valid for lexical/type/range errors, and delegates to facet_constraint_code() for facet violations.

§Constraint code context

  • cvc-datatype-valid (datatypes.html) is the default for lexical/type/range errors. Callers validating at the structures.html level (e.g., element or attribute value checks) should override to cvc-simple-type instead.
  • FacetViolation delegates to facet_constraint_code(), which returns cvc-*-valid for runtime facet checks. Schema-level FacetError variants (DerivationRestriction, FixedFacetViolation, ConflictingFacets, NotApplicable) map to cos-* codes and should not appear during instance validation — they are schema compilation errors.