#[non_exhaustive]pub enum IssueCode {
Show 40 variants
InvalidType {
expected: String,
received: String,
},
TooSmall {
origin: SizeOrigin,
minimum: Value,
inclusive: bool,
},
TooBig {
origin: SizeOrigin,
maximum: Value,
inclusive: bool,
},
InvalidLength {
origin: SizeOrigin,
expected: usize,
},
InvalidString {
validation: StringValidation,
},
InvalidFormat {
format: FormatKind,
},
InvalidDate {
kind: DateKind,
},
InvalidTimezoneOffset {
expected: String,
},
NotInPast {
kind: DateKind,
},
NotInFuture {
kind: DateKind,
},
NotInt,
NotFinite,
NotMultipleOf {
divisor: Value,
},
NotSafeInteger,
InvalidLiteral {
expected: Value,
},
InvalidEnumValue {
options: Vec<String>,
},
InvalidUnion,
InvalidDiscriminator {
options: Vec<Value>,
},
NotUnique,
MissingContains,
DuplicateKey,
InvalidMapEntry,
MissingField,
UnrecognizedField,
PathOutsideBase {
base: String,
},
PathNotAbsolute,
PathNotRelative,
PathNotFound,
PathNotFile,
PathNotDir,
JsonTooDeep {
max_depth: usize,
},
FileTypeNotAllowed {
kind: FileTypeKind,
actual: String,
allowed: Vec<String>,
},
FileTypeDenied {
kind: FileTypeKind,
actual: String,
},
FileTypeUnknown {
kind: FileTypeKind,
},
ChecksumMismatch {
algorithm: String,
},
MissingExif,
SerializeError {
detail: String,
},
IoError,
ParseError,
Custom {
code: String,
},
}Expand description
Validation issue code — describes what went wrong.
Every variant except Custom is produced by vld
itself; Custom is reserved for user-defined codes (refine, custom,
super_refine, IssueBuilder). See the module docs for
the key of every variant.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidType
Wrong JSON type.
Fields
TooSmall
Below a lower bound. minimum is a JSON number, or a string for
Decimal / Date / DateTime origins.
Fields
origin: SizeOriginWhat the bound was measured on.
TooBig
Above an upper bound (see TooSmall).
Fields
origin: SizeOriginWhat the bound was measured on.
InvalidLength
Exact length mismatch.
InvalidString
String format / content check failed.
Fields
validation: StringValidationThe check that failed.
InvalidFormat
A non-string schema could not parse its textual format.
Fields
format: FormatKindThe format that could not be parsed.
InvalidDate
Not a valid date / datetime.
InvalidTimezoneOffset
Datetime offset differs from the required one (±HH:MM).
NotInPast
Date / datetime is not in the past.
NotInFuture
Date / datetime is not in the future.
NotInt
Number is not an integer.
NotFinite
Number is NaN or infinite.
NotMultipleOf
Number is not a multiple of divisor.
NotSafeInteger
Number is outside -(2^53-1)..=2^53-1.
InvalidLiteral
Value differs from the literal.
InvalidEnumValue
String is not one of the enum options.
InvalidUnion
No union variant matched (followed by every variant’s issues).
InvalidDiscriminator
Discriminator value matches no variant.
NotUnique
Array item repeats an earlier one (unique()).
MissingContains
Array lacks the contains(...) value.
DuplicateKey
Map key repeats an earlier one.
InvalidMapEntry
Map entry is not a [key, value] pair.
MissingField
Required field is missing or null.
UnrecognizedField
Field not declared by a strict object.
PathOutsideBase
Path escapes the within(base) directory.
PathNotAbsolute
Path must be absolute.
PathNotRelative
Path must be relative.
PathNotFound
Path does not exist (exists(), file(), dir(), vld::file()).
PathNotFile
Path exists but is not a regular file.
PathNotDir
Path exists but is not a directory.
JsonTooDeep
JSON nesting is deeper than max_depth.
FileTypeNotAllowed
File extension / media type / magic type is not in the allow list.
Fields
kind: FileTypeKindWhich property was checked.
FileTypeDenied
File extension / media type / magic type is on the deny list.
FileTypeUnknown
File media / magic type could not be detected.
Fields
kind: FileTypeKindWhich property could not be detected.
ChecksumMismatch
File hash differs (algorithm is "SHA-256" or "MD5").
MissingExif
Image has no EXIF metadata.
SerializeError
A validated value could not be serialized to JSON.
IoError
Filesystem error.
ParseError
Input is not valid JSON.
Custom
User-defined code.
Implementations§
Source§impl IssueCode
impl IssueCode
Sourcepub fn message_keys(&self) -> Vec<String>
pub fn message_keys(&self) -> Vec<String>
Message-template keys, most specific first.
E.g. ["too_small.string", "too_small"]; exclusive bounds use
too_small_exclusive / too_big_exclusive; Custom codes fall back
to "custom". Resolvers (MessageResolver)
are asked in this order.
Sourcepub fn plural_count(&self) -> Option<u64>
pub fn plural_count(&self) -> Option<u64>
Count selecting a plural template variant: the minimum / maximum
of too_small / too_big or the expected of invalid_length,
when it is a non-negative integer.
Sourcepub fn params(&self) -> Vec<(&'static str, String)>
pub fn params(&self) -> Vec<(&'static str, String)>
Key-value parameters for message templates ({minimum}, {expected}, …).
Sourcepub fn default_message(&self) -> String
pub fn default_message(&self) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IssueCode
impl<'de> Deserialize<'de> for IssueCode
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<IssueCode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<IssueCode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for IssueCode
impl Serialize for IssueCode
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for IssueCode
Auto Trait Implementations§
impl Forget for IssueCode
impl Freeze for IssueCode
impl RefUnwindSafe for IssueCode
impl Send for IssueCode
impl Sync for IssueCode
impl Unpin for IssueCode
impl UnsafeUnpin for IssueCode
impl UnwindSafe for IssueCode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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