[−][src]Enum valid::ConstraintViolation
Represents a constraint violation found by some validation function.
The variants provide different details about a constraint violation. As described in the crate level documentation this crate considers 3 categories of business rules or constraints. Violations of constraints of the different categories might provide different details about the validation.
For example a field validation might provide the field name, the actual value and an example for the expected value. A constraint on the relation of a pair of fields might provide the names of the 2 fields. Stateful constraints may provide a list of parameters that might be useful to describe the reason of the constraint violation.
An implementation of a constraint should choose the most appropriate context for the kind of business rule it is implementing. Here is a table that shows the relation of the implemented context and the variant of the constraint violation type.
Context | Constraint Violation | Construction Method |
---|---|---|
FieldName | Field | invalid_value invalid_optional_value |
RelatedFields | Relation | invalid_relation |
State<S> | State | invalid_state |
The construction methods are a convenient way to construct
ConstraintViolation
s.
ConstraintViolation
can be serialized and deserialized using the serde
crate. To use the serde
support the optional crate feature serde1
must
be enabled.
Variants
Field(InvalidValue)
Violation of a constraint validated in the FieldName
context
Relation(InvalidRelation)
Violation of a constraint validated in the RelatedField
context
State(InvalidState)
Violation of a constraint validated in the State
context
Trait Implementations
impl Clone for ConstraintViolation
[src]
fn clone(&self) -> ConstraintViolation
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ConstraintViolation
[src]
impl<'de> Deserialize<'de> for ConstraintViolation
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for ConstraintViolation
[src]
impl From<InvalidRelation> for ConstraintViolation
[src]
fn from(invalid_relation: InvalidRelation) -> Self
[src]
impl From<InvalidState> for ConstraintViolation
[src]
fn from(invalid_state: InvalidState) -> Self
[src]
impl From<InvalidValue> for ConstraintViolation
[src]
fn from(invalid_value: InvalidValue) -> Self
[src]
impl PartialEq<ConstraintViolation> for ConstraintViolation
[src]
fn eq(&self, other: &ConstraintViolation) -> bool
[src]
fn ne(&self, other: &ConstraintViolation) -> bool
[src]
impl Serialize for ConstraintViolation
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for ConstraintViolation
[src]
Auto Trait Implementations
impl RefUnwindSafe for ConstraintViolation
impl Send for ConstraintViolation
impl Sync for ConstraintViolation
impl Unpin for ConstraintViolation
impl UnwindSafe for ConstraintViolation
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,