Hello. I'm facing a problem. I specify the string type and UUID format. I write not UUID in the field, but JSON passes validation
jsonschema version 0.18
Code:
use jsonschema::JSONSchema;
const SCHEMA: &str = r#"
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"test": {
"type": "string",
"format": "uuid"
}
},
"required": [
"test"
]
}"#;
const JSON_VAL: &str = r#"
{
"test": "Hello world!"
}
"#;
fn main() {
let schema_json: serde_json::Value = serde_json::from_str(SCHEMA).unwrap();
let compiled_schema = JSONSchema::compile(&schema_json).unwrap();
let instance = serde_json::from_str(JSON_VAL).unwrap();
let result = compiled_schema.validate(&instance);
if result.is_ok() {
println!("JSON is valid");
} else {
for error in result.expect_err("Expected validation errors") {
println!("Validation error: {}", error);
}
}
}
Hello. I'm facing a problem. I specify the string type and UUID format. I write not UUID in the field, but JSON passes validation jsonschema version 0.18 Code: