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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
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 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 MultipleOf { pub path: String } impl_err!(MultipleOf, "multiple_of", "Wrong number of the value"); impl_serialize!(MultipleOf); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Maximum { pub path: String } impl_err!(Maximum, "maximum", "Maximum condition is not met"); impl_serialize!(Maximum); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Minimum { pub path: String } impl_err!(Minimum, "minimum", "Minimum condition is not met"); impl_serialize!(Minimum); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct MaxLength { pub path: String } impl_err!(MaxLength, "max_length", "MaxLength condition is not met"); impl_serialize!(MaxLength); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct MinLength { pub path: String } impl_err!(MinLength, "min_length", "MinLength condition is not met"); impl_serialize!(MinLength); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Pattern { pub path: String } impl_err!(Pattern, "pattern", "Pattern condition is not met"); impl_serialize!(Pattern); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct MaxItems { pub path: String } impl_err!(MaxItems, "max_items", "MaxItems condition is not met"); impl_serialize!(MaxItems); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct MinItems { pub path: String } impl_err!(MinItems, "min_items", "MinItems condition is not met"); impl_serialize!(MinItems); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct UniqueItems { pub path: String } impl_err!(UniqueItems, "unique_items", "UniqueItems condition is not met"); impl_serialize!(UniqueItems); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Items { pub path: String, pub detail: String } impl_err!(Items, "items", "Items condition is not met", +detail); impl_serialize!(Items); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct MaxProperties { pub path: String } impl_err!(MaxProperties, "max_properties", "MaxProperties condition is not met"); impl_serialize!(MaxProperties); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct MinProperties { pub path: String } impl_err!(MinProperties, "min_properties", "MinProperties condition is not met"); impl_serialize!(MinProperties); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Required { pub path: String } impl_err!(Required, "required", "This property is required"); impl_serialize!(Required); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Properties { pub path: String, pub detail: String } impl_err!(Properties, "properties", "Property conditions are not met", +detail); impl_serialize!(Properties); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Enum { pub path: String } impl_err!(Enum, "enum", "Enum conditions are not met"); impl_serialize!(Enum); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct AnyOf { pub path: String, pub states: Vec<super::validators::ValidationState> } impl_err!(AnyOf, "any_of", "AnyOf conditions are not met"); impl_serialize!(AnyOf, |err: &AnyOf, map: &mut ::serde_json::Map<String, Value>| { map.insert("states".to_string(), to_value(&err.states).unwrap()) }); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct OneOf { pub path: String, pub states: Vec<super::validators::ValidationState> } impl_err!(OneOf, "one_of", "OneOf conditions are not met"); impl_serialize!(OneOf, |err: &OneOf, map: &mut ::serde_json::Map<String, Value>| { map.insert("states".to_string(), to_value(&err.states).unwrap()) }); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Const { pub path: String } impl_err!(Const, "const", "Const condition is not met"); impl_serialize!(Const); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Contains { pub path: String } impl_err!(Contains, "contains", "Contains condition is not met"); impl_serialize!(Contains); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Not { pub path: String } impl_err!(Not, "not", "Not condition is not met"); impl_serialize!(Not); #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct Format { pub path: String, pub detail: String } impl_err!(Format, "format", "Format is wrong", +detail); impl_serialize!(Format);