Expand description
Validation utilities for input validation and data sanitization Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
This file is part of Ri. The Ri project belongs to the Dunimd Team.
Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
§Validation Module
This module provides comprehensive validation utilities for Ri, including input validation, schema validation, and data verification. It supports various validation rules and provides detailed error messages.
§Key Components
- RiValidator: Core validation trait
- RiValidationRule: Individual validation rule
- RiValidationResult: Validation result with details
- Built-in Validators: Email, URL, length, pattern, range, etc.
§Design Principles
- Composable: Rules can be combined using
and,or,not - Extensible: Easy to implement custom validation rules
- Type-safe: Strongly typed validation for different data types
- Informative: Detailed error messages with field locations
- Async Support: Async validation for I/O-bound checks
- Schema Validation: JSON Schema support for complex structures
§Usage
use ri::validation::{Validator, ValidationRule, RiValidator};
use ri::prelude::*;
let validator = RiValidator::new("user_email")
.not_empty()
.is_email()
.max_length(255);
let result = validator.validate("test@example.com");
assert!(result.is_valid());Structs§
- RiSanitization
Config - RiSanitizer
- RiSchema
Validator - RiValidation
Error - RiValidation
Module - RiValidation
Result - RiValidation
Runner - RiValidator
Builder