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