pub struct EntityValidator<E> { /* private fields */ }Expand description
Composable validator for any entity type E.
Rules are evaluated in registration order and all failures are collected before returning — no fail-fast behaviour.
Implementations§
Source§impl<E> EntityValidator<E>
impl<E> EntityValidator<E>
pub fn new() -> EntityValidator<E>
Sourcepub fn rule(self, rule: impl FieldRule<E> + 'static) -> EntityValidator<E>
pub fn rule(self, rule: impl FieldRule<E> + 'static) -> EntityValidator<E>
Add a rule to this validator (builder pattern).
Sourcepub fn validate(&self, entity: &E) -> ValidationErrors
pub fn validate(&self, entity: &E) -> ValidationErrors
Run all rules and collect errors.
Sourcepub fn validate_result(&self, entity: &E) -> Result<(), ValidationErrors>
pub fn validate_result(&self, entity: &E) -> Result<(), ValidationErrors>
Convenience — returns Ok(()) or Err(ValidationErrors).
Trait Implementations§
Auto Trait Implementations§
impl<E> !RefUnwindSafe for EntityValidator<E>
impl<E> !UnwindSafe for EntityValidator<E>
impl<E> Freeze for EntityValidator<E>
impl<E> Send for EntityValidator<E>
impl<E> Sync for EntityValidator<E>
impl<E> Unpin for EntityValidator<E>
impl<E> UnsafeUnpin for EntityValidator<E>
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
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