ferro_rs/validation/rule.rs
1//! Validation rule trait.
2
3use serde_json::Value;
4
5/// A validation rule that can be applied to a field.
6pub trait Rule: Send + Sync {
7 /// Validate the given value.
8 ///
9 /// Returns `Ok(())` if validation passes, or `Err(message)` if it fails.
10 fn validate(&self, field: &str, value: &Value, data: &Value) -> Result<(), String>;
11
12 /// Get the rule name for error messages.
13 fn name(&self) -> &'static str;
14}