prost_validate/errors/
bytes.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use thiserror::Error;

#[derive(Debug, Clone, Error)]
pub enum Error {
    #[error("must be equal to {0:?}")]
    Const(Vec<u8>),
    #[error("bytes length must be equal to {0}")]
    Len(usize),
    #[error("bytes length must be greater than or equal to {0}")]
    MinLen(usize),
    #[error("bytes length must be less than or equal to {0}")]
    MaxLen(usize),
    #[error("must match pattern {0}")]
    Pattern(String),
    #[error("must have prefix {0:?}")]
    Prefix(Vec<u8>),
    #[error("must have suffix {0:?}")]
    Suffix(Vec<u8>),
    #[error("must contain {0:?}")]
    Contains(Vec<u8>),
    #[error("must be in {0:?}")]
    In(Vec<Vec<u8>>),
    #[error("must not be in {0:?}")]
    NotIn(Vec<Vec<u8>>),
    #[error("must be a valid IP address")]
    Ip,
    #[error("must be a valid IPv4 address")]
    Ipv4,
    #[error("must be a valid IPv6 address")]
    Ipv6,
}

impl From<Error> for super::Error {
    fn from(value: Error) -> Self {
        Self::Bytes(value)
    }
}