Skip to main content

SchemaValidator

Trait SchemaValidator 

Source
pub trait SchemaValidator: Send + Sync {
    // Required methods
    fn validate(
        &self,
        value: &Value,
        field: &str,
    ) -> Result<(), ValidationError>;
    fn is_required(&self) -> bool;
    fn default_value(&self) -> Option<Value>;
    fn schema_type(&self) -> &'static str;
}
Expand description

Defines validation rules and metadata introspection for a specific schema type.

Required Methods§

Source

fn validate(&self, value: &Value, field: &str) -> Result<(), ValidationError>

Validates the given Value against the structural rules of this schema.

§Errors

Returns a ValidationError if the value deviates from schema requirements.

Source

fn is_required(&self) -> bool

Returns true if the field must be supplied and lacks a default value.

Source

fn default_value(&self) -> Option<Value>

Yields the fallback Value if this optional/default field is omitted.

Source

fn schema_type(&self) -> &'static str

Static string representing the readable type name.

Implementors§