prost_validate/errors/
string.rs1use thiserror::Error;
2
3#[derive(Debug, Clone, Error)]
4pub enum Error {
5 #[error("must be equal to \"{0}\"")]
6 Const(String),
7 #[error("characters length must be equal to {0}")]
8 Len(usize),
9 #[error("characters length must be greater than or equal to {0}")]
10 MinLen(usize),
11 #[error("characters length must be less than or equal to {0}")]
12 MaxLen(usize),
13 #[error("bytes length must be equal to {0}")]
14 LenBytes(usize),
15 #[error("bytes length must be greater than or equal to {0}")]
16 MinLenBytes(usize),
17 #[error("bytes length must be less than or equal to {0}")]
18 MaxLenBytes(usize),
19 #[error("must match pattern \"{0}\"")]
20 Pattern(String),
21 #[error("must have prefix \"{0}\"")]
22 Prefix(String),
23 #[error("must have suffix \"{0}\"")]
24 Suffix(String),
25 #[error("must contain \"{0}\"")]
26 Contains(String),
27 #[error("must not contain \"{0}\"")]
28 NotContains(String),
29 #[error("must be in {0:?}")]
30 In(Vec<String>),
31 #[error("must not be in {0:?}")]
32 NotIn(Vec<String>),
33 #[error("must be a valid email address")]
34 Email,
35 #[error("must be a valid hostname")]
36 Hostname,
37 #[error("must be a valid IP address")]
38 Ip,
39 #[error("must be a valid IPv4 address")]
40 Ipv4,
41 #[error("must be a valid IPv6 address")]
42 Ipv6,
43 #[error("must be a valid URI")]
44 Uri,
45 #[error("must be a valid URI ref")]
46 UriRef,
47 #[error("must be a valid hostname or IP address")]
48 Address,
49 #[error("must be a valid UUID")]
50 Uuid,
51 #[error("must be a valid HTTP Header name")]
52 HttpHeaderName,
53 #[error("must be a valid HTTP Header value")]
54 HttpHeaderValue,
55}
56
57impl From<Error> for super::Error {
58 fn from(value: Error) -> Self {
59 Self::String(value)
60 }
61}