prost_validate/errors/
bytes.rs

1use thiserror::Error;
2
3#[derive(Debug, Clone, Error)]
4pub enum Error {
5    #[error("must be equal to {0:?}")]
6    Const(Vec<u8>),
7    #[error("bytes length must be equal to {0}")]
8    Len(usize),
9    #[error("bytes length must be greater than or equal to {0}")]
10    MinLen(usize),
11    #[error("bytes length must be less than or equal to {0}")]
12    MaxLen(usize),
13    #[error("must match pattern {0}")]
14    Pattern(String),
15    #[error("must have prefix {0:?}")]
16    Prefix(Vec<u8>),
17    #[error("must have suffix {0:?}")]
18    Suffix(Vec<u8>),
19    #[error("must contain {0:?}")]
20    Contains(Vec<u8>),
21    #[error("must be in {0:?}")]
22    In(Vec<Vec<u8>>),
23    #[error("must not be in {0:?}")]
24    NotIn(Vec<Vec<u8>>),
25    #[error("must be a valid IP address")]
26    Ip,
27    #[error("must be a valid IPv4 address")]
28    Ipv4,
29    #[error("must be a valid IPv6 address")]
30    Ipv6,
31}
32
33impl From<Error> for super::Error {
34    fn from(value: Error) -> Self {
35        Self::Bytes(value)
36    }
37}