Skip to main content

ValidationError

Enum ValidationError 

Source
pub enum ValidationError {
Show 60 variants NotPositive(i128), Negative(i128), Zero, NotFinite(String), FloatNotPositive(f64), FloatNegative(f64), FloatOutOfRange { value: f64, min: f64, max: f64, }, OutOfRange { value: i128, min: i128, max: i128, }, EmptyString, StringTooLong { actual: usize, max: usize, }, StringTooShort { actual: usize, min: usize, }, NotTrue, NotFalse, NotAlphabetic(char), NotNumeric(char), NotAlphanumeric(char), WrongUuidVersion { expected: u8, got: u8, }, NilUuid, DurationNotPositive, NotPrivateIp, NotPublicIp, ExpectedIpv4GotIpv6, ExpectedIpv6GotIpv4, NotLoopback, PathDoesNotExist(String), PathNotReadable(String), PathNotDirectory(String), PathNotFile(String), DateTimeTooEarly { value: String, threshold: String, }, DateTimeTooLate { value: String, threshold: String, }, EmptyCollection, OptionIsNone, ResultIsErr, WrongJsonType { expected: String, got: String, }, JsonIsNull, UrlInvalid, InvalidUrlSyntax, UrlMissingAuthority, UrlNotAbsolute, UrlNotHttps, UrlNotHttp, InvalidRegexSyntax, UrlNoHost, UrlCannotBeBase, RegexInvalid, InvalidUuidVariant, NotUnicastMac, NotMulticastMac, NotUniversalMac, NotLocalMac, PortIsZero, PortNotPrivileged(u16), PortIsPrivileged(u16), PathContainsNull, PathNotAbsolute(String), PathNotRelative(String), InvalidUtf8, TooLong { max: usize, actual: usize, }, StatusCodeInvalid(u16), HeaderInvalid(String),
}
Expand description

Error type for contract validation failures.

Variants§

§

NotPositive(i128)

Value is not positive (must be > 0).

§

Negative(i128)

Value is negative (must be >= 0).

§

Zero

Value is zero (must be non-zero).

§

NotFinite(String)

Value is not finite (NaN or infinite).

§

FloatNotPositive(f64)

Float value is not positive (must be > 0.0).

§

FloatNegative(f64)

Float value is negative (must be >= 0.0).

§

FloatOutOfRange

Float value is out of range.

Fields

§value: f64

The value that was out of range.

§min: f64

Minimum allowed value.

§max: f64

Maximum allowed value.

§

OutOfRange

Value is out of range.

Fields

§value: i128

The value that was out of range.

§min: i128

Minimum allowed value.

§max: i128

Maximum allowed value.

§

EmptyString

String is empty (must be non-empty).

§

StringTooLong

String exceeds maximum length.

Fields

§actual: usize

Actual length.

§max: usize

Maximum allowed length.

§

StringTooShort

String is below minimum length.

Fields

§actual: usize

Actual length.

§min: usize

Minimum allowed length.

§

NotTrue

Bool value is not true (must be true).

§

NotFalse

Bool value is not false (must be false).

§

NotAlphabetic(char)

Char is not alphabetic.

§

NotNumeric(char)

Char is not numeric.

§

NotAlphanumeric(char)

Char is not alphanumeric.

§

WrongUuidVersion

UUID is wrong version.

Fields

§expected: u8

Expected version number.

§got: u8

Actual version number.

§

NilUuid

UUID is nil.

§

DurationNotPositive

Duration is not positive (must be > zero).

§

NotPrivateIp

IP address is not private (not in RFC 1918 or RFC 4193 ranges).

§

NotPublicIp

IP address is not public.

§

ExpectedIpv4GotIpv6

Expected IPv4, got IPv6.

§

ExpectedIpv6GotIpv4

Expected IPv6, got IPv4.

§

NotLoopback

IP address is not loopback.

§

PathDoesNotExist(String)

Path does not exist on filesystem.

§

PathNotReadable(String)

Path is not readable.

§

PathNotDirectory(String)

Path is not a directory.

§

PathNotFile(String)

Path is not a file.

§

DateTimeTooEarly

DateTime is too early (before threshold).

Fields

§value: String

The value that was too early.

§threshold: String

The threshold it must be after.

§

DateTimeTooLate

DateTime is too late (after threshold).

Fields

§value: String

The value that was too late.

§threshold: String

The threshold it must be before.

§

EmptyCollection

Collection is empty (must be non-empty).

§

OptionIsNone

Option is None (must be Some).

§

ResultIsErr

Result is Err (must be Ok).

§

WrongJsonType

JSON Value is wrong type.

Fields

§expected: String

Expected JSON type.

§got: String

Actual JSON type.

§

JsonIsNull

JSON Value is null.

§

UrlInvalid

URL is invalid or malformed.

§

InvalidUrlSyntax

URL syntax is invalid (RFC 3986).

§

UrlMissingAuthority

URL is missing authority component.

§

UrlNotAbsolute

URL is not absolute (missing scheme + authority).

§

UrlNotHttps

URL scheme is not HTTPS.

§

UrlNotHttp

URL scheme is not HTTP.

§

InvalidRegexSyntax

Regex syntax is invalid.

§

UrlNoHost

URL has no host component.

§

UrlCannotBeBase

URL cannot be a base for relative URLs.

§

RegexInvalid

Regex pattern is invalid or cannot be compiled.

§

InvalidUuidVariant

UUID variant bits are invalid (not RFC 4122 10xx pattern).

§

NotUnicastMac

MAC address is not unicast (is multicast).

§

NotMulticastMac

MAC address is not multicast (is unicast).

§

NotUniversalMac

MAC address is not universal (is locally administered).

§

NotLocalMac

MAC address is not locally administered (is universal).

§

PortIsZero

Port number is zero (invalid for binding).

§

PortNotPrivileged(u16)

Port number is not privileged (>= 1024).

§

PortIsPrivileged(u16)

Port number is privileged (< 1024).

§

PathContainsNull

Path contains null byte (invalid on Unix).

§

PathNotAbsolute(String)

Path is not absolute (does not start with /).

§

PathNotRelative(String)

Path is not relative (starts with /).

§

InvalidUtf8

UTF-8 validation failed.

§

TooLong

Value exceeds maximum length (generic).

Fields

§max: usize

Maximum allowed length.

§actual: usize

Actual length.

§

StatusCodeInvalid(u16)

HTTP status code is invalid (must be 100–999).

§

HeaderInvalid(String)

HTTP header name or value is invalid.

Trait Implementations§

Source§

impl Clone for ValidationError

Source§

fn clone(&self) -> ValidationError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValidationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ValidationError

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ValidationError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ValidationError> for ElicitError

Source§

fn from(err: ValidationError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ValidationError

Source§

fn eq(&self, other: &ValidationError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ValidationError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Refines<T> for T
where T: 'static,