valico/json_schema/validators/
not.rs
1use serde_json::{Value};
2use url;
3
4use super::super::errors;
5use super::super::scope;
6
7#[allow(missing_copy_implementations)]
8pub struct Not {
9 pub url: url::Url
10}
11
12impl super::Validator for Not {
13 fn validate(&self, val: &Value, path: &str, scope: &scope::Scope) -> super::ValidationState {
14 let schema = scope.resolve(&self.url);
15 let mut state = super::ValidationState::new();
16
17 if schema.is_some() {
18 if schema.unwrap().validate_in(val, path).is_valid() {
19 state.errors.push(Box::new(
20 errors::Not {
21 path: path.to_string()
22 }
23 ))
24 }
25 } else {
26 state.missing.push(self.url.clone());
27 }
28
29 state
30 }
31}