Struct Validator

Source
pub struct Validator;
Expand description

Protocol validation utilities

Implementations§

Source§

impl Validator

Source

pub fn validate_uuid(uuid_str: &str) -> Result<Uuid>

Validate a UUID string

§Errors

Returns an error if the string is not a valid UUID format

Source

pub fn validate_non_empty(value: &str, field_name: &str) -> Result<()>

Validate that a string is not empty

§Errors

Returns an error if the string is empty or contains only whitespace

Source

pub fn validate_tool_name(name: &str) -> Result<()>

Validate a tool name (must be alphanumeric with underscores)

§Errors

Returns an error if the name is empty or contains invalid characters

Source

pub fn validate_resource_uri(uri: &str) -> Result<()>

Validate a resource URI

§Errors

Returns an error if the URI is empty or contains control characters

Source

pub fn validate_json_schema(schema: &Value) -> Result<()>

Validate JSON schema

§Errors

Returns an error if the schema is not a valid JSON object with a type field

Source

pub fn validate_tool_arguments( args: &HashMap<String, Value>, schema: &Value, ) -> Result<()>

Validate tool arguments against a schema

§Errors

Returns an error if required arguments are missing from the provided arguments

Source

pub fn validate_pagination( cursor: Option<&str>, limit: Option<u32>, ) -> Result<()>

Validate pagination parameters

§Errors

Returns an error if cursor is empty, limit is 0, or limit exceeds 1000

Source

pub fn validate_prompt_name(name: &str) -> Result<()>

Validate prompt name

§Errors

Returns an error if the name is empty or contains invalid characters

Source

pub fn validate_struct<T: Validate>(item: &T) -> Result<()>

Validate a struct using the validator crate

§Errors

Returns an error if the struct fails validation according to its validation rules

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,