Skip to content

Commit a7067d3

Browse files
committed
Use input type json when validating a json schema
1 parent 7fa450d commit a7067d3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/validators/json.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pyo3::types::PyDict;
55
use jiter::JsonValue;
66

77
use crate::errors::{ErrorType, ErrorTypeDefaults, ValError, ValLineError, ValResult};
8-
use crate::input::{EitherBytes, Input, ValidationMatch};
8+
use crate::input::{EitherBytes, Input, InputType, ValidationMatch};
99
use crate::tools::SchemaDict;
1010

1111
use super::{build_validator, BuildValidator, CombinedValidator, DefinitionsBuilder, ValidationState, Validator};
@@ -58,7 +58,10 @@ impl Validator for JsonValidator {
5858
match self.validator {
5959
Some(ref validator) => {
6060
let json_value = JsonValue::parse(json_bytes, true).map_err(|e| map_json_err(input, e, json_bytes))?;
61-
validator.validate(py, &json_value, state)
61+
let mut json_state = state.rebind_extra(|e| {
62+
e.input_type = InputType::Json;
63+
});
64+
validator.validate(py, &json_value, &mut json_state)
6265
}
6366
None => {
6467
let obj =

0 commit comments

Comments
 (0)