Skip to main content

Module validator

Module validator 

Source
Expand description

Version-independent JSON Schema tools: validate a JSON value against a JSON Schema, inspect and combine schemas, rewrite a 2020-12 schema into the OpenAPI 3.0 dialect. No schemars dependency; the schemars modules re-export every item.

use vld_openapi::validator::*;

let schema = serde_json::json!({
    "type": "object",
    "required": ["name"],
    "properties": { "name": { "type": "string", "minLength": 1 } }
});
assert!(validate_with_schema(&schema, &serde_json::json!({"name": "Alice"})).is_ok());
assert!(is_required(&schema, "name"));
assert_eq!(list_properties(&schema)[0].name, "name");

Structs§

PropertyInfo
Information about a single property in a JSON Schema object.

Enums§

VldSchemarsError
Error returned by schemars → vld validation.

Functions§

get_property
Get the property schema for a specific field.
is_required
Check if a field is required in a JSON Schema.
list_properties
Extract property information from a JSON Schema object.
overlay_constraints
Overlay additional constraints from one schema onto another.
schema_type
Get the “type” field from a JSON Schema.
schemas_equal
Check if two JSON Schema values are structurally equal.
to_openapi3
Rewrite vld’s JSON Schema (2020-12) into the OpenAPI 3.0 dialect, applied when the generator uses SchemaSettings::openapi3():
validate_with_schema
Validate a serde_json::Value against a JSON Schema.