[][src]Enum valid::Value

pub enum Value {
    String(String),
    Integer(i32),
    Long(i64),
    Float(f32),
    Double(f64),
    Boolean(bool),
    Decimal(BigDecimal),
    Date(NaiveDate),
    DateTime(DateTime<Utc>),
    BigInteger(BigInt),
}

A Value represents a value of certain type.

The purpose of a Value is to include field values or parameters in ConstraintViolations in a type that allows to display the value in a localized format as part of a user facing error message.

It has variants for the basic types that are used in most applications.

Important types of 3rd party crates are supported through optional crate features:

supported typecrate feature3rd party crate
BigIntnum-bigintnum-bigint
BigDecimalbigdecimalbigdecimal
NaiveDatechronochrono
DateTimechronochrono

The From trait is implemented for the underlying types. Additionally there are implementations of the From trait for the primitive types i8, i16, i64, u8, u16, u32, u64.

u32 values greater than i32::max_value() are converted to Long(i64).

Panics

Converting u64 values greater than i64::max_value() has an unreliable behavior and might panic.

Notes

The list of supported types is very opinionated and may not fit all kind of applications. Please file and issue if you feel that support for another type may be useful!

Variants

String(String)

a string value

Integer(i32)

a 32bit signed integer value

Long(i64)

a 64bit signed integer value

Float(f32)

a 32bit float value

Double(f64)

a 64bit float value

Boolean(bool)

a boolean value

Decimal(BigDecimal)

a decimal value

Date(NaiveDate)

a date value

DateTime(DateTime<Utc>)

a value with date, time and timezone

BigInteger(BigInt)

a big integer value

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl<'de> Deserialize<'de> for Value[src]

impl Display for Value[src]

impl From<BigDecimal> for Value[src]

impl From<BigInt> for Value[src]

impl<Z> From<DateTime<Z>> for Value where
    Z: TimeZone
[src]

impl From<NaiveDate> for Value[src]

impl From<String> for Value[src]

impl From<bool> for Value[src]

impl From<f32> for Value[src]

impl From<f64> for Value[src]

impl From<i16> for Value[src]

impl From<i32> for Value[src]

impl From<i64> for Value[src]

impl From<i8> for Value[src]

impl From<u16> for Value[src]

impl From<u32> for Value[src]

impl From<u64> for Value[src]

impl From<u8> for Value[src]

impl PartialEq<Value> for Value[src]

impl Serialize for Value[src]

impl StructuralPartialEq for Value[src]

impl TryFrom<usize> for Value[src]

type Error = &'static str

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Value

impl Send for Value

impl Sync for Value

impl Unpin for Value

impl UnwindSafe for Value

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.