pub struct Validator<'a> { /* private fields */ }Expand description
Fluent per-field validator. See module docs.
Implementations§
Source§impl<'a> Validator<'a>
impl<'a> Validator<'a>
pub fn new(input: &'a PluginInput) -> Self
Sourcepub fn require_str(&mut self, key: &str) -> &mut Self
pub fn require_str(&mut self, key: &str) -> &mut Self
Require a present, non-empty string.
Sourcepub fn require_enum(&mut self, key: &str, allowed: &[&str]) -> &mut Self
pub fn require_enum(&mut self, key: &str, allowed: &[&str]) -> &mut Self
Require a string field whose value is one of allowed.
Sourcepub fn require_gtin(&mut self, key: &str) -> &mut Self
pub fn require_gtin(&mut self, key: &str) -> &mut Self
Require a 14-digit GS1 GTIN string with a valid check digit.
Sourcepub fn require_country(&mut self, key: &str) -> &mut Self
pub fn require_country(&mut self, key: &str) -> &mut Self
Require a recognized ISO 3166-1 alpha-2 country code.
Sourcepub fn require_positive(&mut self, key: &str) -> &mut Self
pub fn require_positive(&mut self, key: &str) -> &mut Self
Require a present, finite number greater than 0.
Sourcepub fn require_non_negative(&mut self, key: &str) -> &mut Self
pub fn require_non_negative(&mut self, key: &str) -> &mut Self
Require a present, finite number greater than or equal to 0.
Sourcepub fn require_pct(&mut self, key: &str) -> &mut Self
pub fn require_pct(&mut self, key: &str) -> &mut Self
Require a present, finite number in [0, 100].
Sourcepub fn require_positive_int(&mut self, key: &str) -> &mut Self
pub fn require_positive_int(&mut self, key: &str) -> &mut Self
Require a present non-negative integer that is at least 1.
Sourcepub fn require_bool(&mut self, key: &str) -> &mut Self
pub fn require_bool(&mut self, key: &str) -> &mut Self
Require a present boolean.
Sourcepub fn require_non_empty_array(&mut self, key: &str) -> &mut Self
pub fn require_non_empty_array(&mut self, key: &str) -> &mut Self
Require a present, non-empty array.
Sourcepub fn optional_pct(&mut self, key: &str) -> &mut Self
pub fn optional_pct(&mut self, key: &str) -> &mut Self
If present (and non-null), the value must be a finite number in [0, 100].
Sourcepub fn finish(&mut self) -> Result<(), PluginError>
pub fn finish(&mut self) -> Result<(), PluginError>
Finish validation, returning every collected error at once.
Auto Trait Implementations§
impl<'a> Freeze for Validator<'a>
impl<'a> RefUnwindSafe for Validator<'a>
impl<'a> Send for Validator<'a>
impl<'a> Sync for Validator<'a>
impl<'a> Unpin for Validator<'a>
impl<'a> UnsafeUnpin for Validator<'a>
impl<'a> UnwindSafe for Validator<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more