abstract_std/objects/validation/
error.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
38
39
40
41
42
43
44
45
use thiserror::Error;

use super::verifiers::DANGEROUS_CHARS;

#[derive(Error, Debug, PartialEq)]
pub enum ValidationError {
    #[error("description too short, must be at least {0} characters")]
    DescriptionInvalidShort(usize),

    #[error("description too long, must be at most {0} characters")]
    DescriptionInvalidLong(usize),

    #[error(
        "description contains dangerous characters, including one of {:?}",
        DANGEROUS_CHARS
    )]
    DescriptionContainsDangerousCharacters {},

    #[error("link too short, must be at least {0} characters")]
    LinkInvalidShort(usize),

    #[error("link too long, must be at most {0} characters")]
    LinkInvalidLong(usize),

    #[error("link must start with http:// or https://")]
    LinkInvalidFormat {},

    #[error(
        "link contains dangerous characters, including one of {:?}",
        DANGEROUS_CHARS
    )]
    LinkContainsDangerousCharacters {},

    #[error("title/gov-type too short, must be at least {0} characters")]
    TitleInvalidShort(usize),

    #[error("title/gov-type too long, must be at most {0} characters")]
    TitleInvalidLong(usize),

    #[error(
        "title/gov-type contains dangerous characters, including one of {:?}",
        DANGEROUS_CHARS
    )]
    TitleContainsDangerousCharacters {},
}