Validate

Trait Validate 

Source
pub trait Validate: ToString {
    // Required method
    fn validate(&self) -> Vec<ValidationError>;

    // Provided methods
    fn is_valid(&self) -> bool { ... }
    fn check_validity(&self) -> Result<(), ValidationError> { ... }
}
Expand description

xAPI mandates certain constraints on the values of some properties of types it defines. Our API binding structures however limit the Rust type of almost all fields to be Strings or derivative types based on Strings. This is to allow deserializing all types from the wire even when their values violate those constraints.

Required Methods§

Source

fn validate(&self) -> Vec<ValidationError>

Validate the instance and return a potentially empty collection of ValidationError.

Provided Methods§

Source

fn is_valid(&self) -> bool

Convenience method to quickly assert if the type implementing this trait is indeed valid.

Return TRUE if calling validate() did not return any ValidationError. Return FALSE otherwise.

Source

fn check_validity(&self) -> Result<(), ValidationError>

Convenience method that checks the validity of a Validate instance and raises a ValidationError if it was found to be invalid.

Implementors§