tatami.validation module¶
Data validation utilities for Tatami framework.
This module provides comprehensive validation for input parameters based on type annotations.
- exception tatami.validation.ValidationException(field_name, value, expected_type, message=None)[source]¶
Bases:
Exception
Custom exception for validation errors.
- Parameters:
field_name (str)
value (Any)
expected_type (type)
message (str)
- tatami.validation.create_multiple_validation_errors_response(errors)[source]¶
Create a response for multiple validation errors using RFC 7807 Problem Details format.
- Parameters:
errors (list[ValidationException]) – List of validation exceptions
- Returns:
JSONResponse with all error details in RFC 7807 format
- Return type:
JSONResponse
- tatami.validation.create_validation_error_response(error)[source]¶
Create a standardized error response for validation failures using RFC 7807 Problem Details format.
- Parameters:
error (ValidationException) – The validation exception
- Returns:
JSONResponse with error details in RFC 7807 format
- Return type:
JSONResponse
- tatami.validation.validate_parameter(value, annotation, field_name, allow_none=False)[source]¶
Validate a parameter value against its type annotation.
- Parameters:
value (Any) – The value to validate
annotation (type) – The type annotation
field_name (str) – Name of the field for error reporting
allow_none (bool) – Whether None values are allowed
- Returns:
The validated and converted value
- Raises:
ValidationException – If validation fails
- Return type:
Any