pub struct SchemaValidator { /* private fields */ }Available on crate feature
guardrail only.Expand description
JSON Schema validator guardrail for enforcing output structure
Implementations§
Source§impl SchemaValidator
impl SchemaValidator
Sourcepub fn new(schema: &Value) -> Result<SchemaValidator, GuardrailError>
Available on crate feature schema only.
pub fn new(schema: &Value) -> Result<SchemaValidator, GuardrailError>
schema only.Create a new schema validator from a JSON Schema value
Sourcepub fn with_name(self, name: impl Into<String>) -> SchemaValidator
Available on crate feature schema only.
pub fn with_name(self, name: impl Into<String>) -> SchemaValidator
schema only.Create with a custom name
Sourcepub fn with_severity(self, severity: Severity) -> SchemaValidator
Available on crate feature schema only.
pub fn with_severity(self, severity: Severity) -> SchemaValidator
schema only.Set severity level
Trait Implementations§
Source§impl Guardrail for SchemaValidator
impl Guardrail for SchemaValidator
Source§fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
content: &'life1 Content,
) -> Pin<Box<dyn Future<Output = GuardrailResult> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SchemaValidator: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
content: &'life1 Content,
) -> Pin<Box<dyn Future<Output = GuardrailResult> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SchemaValidator: 'async_trait,
Validate content and return result
Source§fn run_parallel(&self) -> bool
fn run_parallel(&self) -> bool
Whether to run in parallel with other guardrails (default: true)
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