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