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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use std::error::{Error};
use super::super::common::error::ValicoError;
use serde_json::{Value, to_value};
use serde::{Serialize, Serializer};

#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct Required {
    pub path: String
}
impl_err!(Required, "required", "This field is required");
impl_serialize!(Required);


#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct WrongType {
    pub path: String,
    pub detail: String
}
impl_err!(WrongType, "wrong_type", "Type of the value is wrong", +detail);
impl_serialize!(WrongType);

#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct WrongValue {
    pub path: String,
    pub detail: Option<String>,
}
impl_err!(WrongValue, "wrong_value", "The value is wrong or mailformed", +opt_detail);
impl_serialize!(WrongValue);

#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct MutuallyExclusive {
    pub path: String,
    pub detail: Option<String>,
    pub params: Vec<String>
}
impl_err!(MutuallyExclusive, "mutually_exclusive", "The values are mutually exclusive", +opt_detail);
impl_serialize!(MutuallyExclusive, |err: &MutuallyExclusive, map: &mut ::serde_json::Map<String, Value>| {
    map.insert("params".to_string(), to_value(&err.params).unwrap());
});

#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct ExactlyOne {
    pub path: String,
    pub detail: Option<String>,
    pub params: Vec<String>
}
impl_err!(ExactlyOne, "exactly_one", "Exacly one of the values must be present", +opt_detail);
impl_serialize!(ExactlyOne, |err: &ExactlyOne, map: &mut ::serde_json::Map<String, Value>| {
    map.insert("params".to_string(), to_value(&err.params).unwrap())
});


#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct AtLeastOne {
    pub path: String,
    pub detail: Option<String>,
    pub params: Vec<String>
}
impl_err!(AtLeastOne, "at_least_one", "At least one of the values must be present", +opt_detail);
impl_serialize!(AtLeastOne, |err: &AtLeastOne, map: &mut ::serde_json::Map<String, Value>| {
    map.insert("params".to_string(), to_value(&err.params).unwrap())
});