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§
Sourcefn validate(&self, value: &Value, field: &str) -> Result<(), ValidationError>
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.
Sourcefn is_required(&self) -> bool
fn is_required(&self) -> bool
Returns true if the field must be supplied and lacks a default value.
Sourcefn default_value(&self) -> Option<Value>
fn default_value(&self) -> Option<Value>
Yields the fallback Value if this optional/default field is omitted.
Sourcefn schema_type(&self) -> &'static str
fn schema_type(&self) -> &'static str
Static string representing the readable type name.