pub struct ParameterValidator { /* private fields */ }Expand description
Parameter validator that uses JSON Schema
Implementations§
Source§impl ParameterValidator
impl ParameterValidator
Sourcepub fn new(schema: Value) -> Result<Self, String>
pub fn new(schema: Value) -> Result<Self, String>
Create a new parameter validator from a JSON Schema
The schema should describe all parameters with their types and constraints. Each property MUST have a “source” field indicating where the parameter comes from.
§Errors
Returns an error if the schema is invalid or malformed.
Sourcepub fn requires_headers(&self) -> bool
pub fn requires_headers(&self) -> bool
Whether this validator needs access to request headers.
Whether this validator needs access to request cookies.
Sourcepub fn has_params(&self) -> bool
pub fn has_params(&self) -> bool
Whether the validator has any parameter definitions.
Sourcepub fn validate_and_extract(
&self,
query_params: &Value,
raw_query_params: &HashMap<String, Vec<String>>,
path_params: &HashMap<String, String>,
headers: &HashMap<String, String>,
cookies: &HashMap<String, String>,
) -> Result<Value, ValidationError>
pub fn validate_and_extract( &self, query_params: &Value, raw_query_params: &HashMap<String, Vec<String>>, path_params: &HashMap<String, String>, headers: &HashMap<String, String>, cookies: &HashMap<String, String>, ) -> Result<Value, ValidationError>
Validate and extract parameters from the request
This builds a JSON object from query/path/header/cookie params and validates it. It performs type coercion (e.g., “123” → 123) based on the schema.
Returns the validated JSON object that can be directly converted to Python kwargs.
§Errors
Returns a validation error if parameter validation fails.
Trait Implementations§
Source§impl Clone for ParameterValidator
impl Clone for ParameterValidator
Source§fn clone(&self) -> ParameterValidator
fn clone(&self) -> ParameterValidator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more