poem_openapi/validation/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::fmt::Display;

mod max_items;
mod max_length;
mod max_properties;
mod maximum;
mod min_items;
mod min_length;
mod min_properties;
mod minimum;
mod multiple_of;
mod pattern;
mod unique_items;

pub use max_items::MaxItems;
pub use max_length::MaxLength;
pub use max_properties::MaxProperties;
pub use maximum::Maximum;
pub use min_items::MinItems;
pub use min_length::MinLength;
pub use min_properties::MinProperties;
pub use minimum::Minimum;
pub use multiple_of::MultipleOf;
pub use pattern::Pattern;
pub use unique_items::UniqueItems;

use crate::registry::MetaSchema;

/// Represents a validator for validate the input value.
pub trait Validator<T>: Display {
    /// Check the value is valid.
    fn check(&self, value: &T) -> bool;
}

pub trait ValidatorMeta {
    fn update_meta(&self, meta: &mut MetaSchema);
}