pub struct Validator<'a> { /* private fields */ }Implementations§
Source§impl<'a> Validator<'a>
impl<'a> Validator<'a>
pub fn new( data: &'a HashMap<String, Value>, rules: Vec<(&'a str, Vec<Rule>)>, ) -> Self
pub fn with_messages(self, messages: HashMap<String, String>) -> Self
Sourcepub fn with_database(self, db: DatabaseConnection) -> Self
pub fn with_database(self, db: DatabaseConnection) -> Self
Use an explicit database connection for DB-backed rules (unique /
exists). Defaults to the global connection set via
crate::models::set_global_database.
pub fn validate(&self) -> Result<(), ValidationErrors>
Sourcepub async fn validate_async(&self) -> Result<(), ValidationErrors>
pub async fn validate_async(&self) -> Result<(), ValidationErrors>
Async variant of Validator::validate that also resolves DB-backed
rules (unique / exists) against a database connection. When no
DB-backed rule is present this is equivalent to Validator::validate
and does not require a database connection.
pub fn passes(&self) -> bool
pub fn fails(&self) -> bool
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Validator<'a>
impl<'a> !UnwindSafe for Validator<'a>
impl<'a> Freeze 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>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more