pub struct SchemaValidator;Available on crate feature
azure_policy only.Expand description
Validator for checking if a Value conforms to a Schema.
Implementations§
Source§impl SchemaValidator
impl SchemaValidator
Sourcepub fn validate(value: &Value, schema: &Schema) -> Result<(), ValidationError>
pub fn validate(value: &Value, schema: &Schema) -> Result<(), ValidationError>
Validates a Value against a Schema.
§Arguments
value- The Value to validateschema- The Schema to validate against
§Returns
Ok(())if the value conforms to the schemaErr(ValidationError)if validation fails
§Example
use regorus::schema::{Schema, validate::SchemaValidator};
use regorus::Value;
use serde_json::json;
let schema_json = json!({
"type": "string",
"minLength": 1,
"maxLength": 10
});
let schema = Schema::from_serde_json_value(schema_json).unwrap();
let value = Value::from("hello");
let result = SchemaValidator::validate(&value, &schema);
assert!(result.is_ok());Auto Trait Implementations§
impl Freeze for SchemaValidator
impl RefUnwindSafe for SchemaValidator
impl Send for SchemaValidator
impl Sync for SchemaValidator
impl Unpin for SchemaValidator
impl UnsafeUnpin for SchemaValidator
impl UnwindSafe for SchemaValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more