Trait Validator

Source
pub trait Validator:
    Send
    + Sync
    + Any {
    // Required methods
    fn name(&self) -> &'static str;
    fn validate(&self, value: &Value) -> Result<(), String>;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn downcast_ref<U: Any>(&self) -> Option<&U>
       where Self: Sized { ... }
}

Required Methods§

Source

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

Source

fn validate(&self, value: &Value) -> Result<(), String>

Source

fn as_any(&self) -> &dyn Any

Provided Methods§

Source

fn downcast_ref<U: Any>(&self) -> Option<&U>
where Self: Sized,

Trait Implementations§

Source§

impl FromDirective for Box<dyn Validator>

Source§

fn from_directive(directive: Directive) -> Result<Self, String>
where Self: Sized,

Source§

impl Validator for Box<dyn Validator>

Source§

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

Source§

fn validate(&self, value: &Value) -> Result<(), String>

Source§

fn as_any(&self) -> &dyn Any

Source§

fn downcast_ref<U: Any>(&self) -> Option<&U>
where Self: Sized,

Implementations on Foreign Types§

Source§

impl Validator for Box<dyn Validator>

Source§

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

Source§

fn validate(&self, value: &Value) -> Result<(), String>

Source§

fn as_any(&self) -> &dyn Any

Source§

impl<T: Validator> Validator for Box<T>

Source§

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

Source§

fn validate(&self, value: &Value) -> Result<(), String>

Source§

fn as_any(&self) -> &dyn Any

Implementors§