Skip to main content

async_validator_map_for

Function async_validator_map_for 

Source
pub async fn async_validator_map_for(
    schema: &Value,
) -> Result<ValidatorMap, ValidationError<'static>>
Expand description

Create a ValidatorMap from the input schema using async retrieval for external references.

Async counterpart to validator_map_for. Note that only construction is asynchronous — validation itself is always synchronous.

§Examples

use serde_json::json;

let schema = json!({"$defs": {"User": {"type": "object", "required": ["name"]}}});
let map = jsonschema::async_validator_map_for(&schema).await?;
assert!(map["#/$defs/User"].is_valid(&json!({"name": "Bob"})));

§Errors

Returns an error if the schema is invalid or external references cannot be resolved.