Skip to main content

Module validation

Module validation 

Source
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.0

Unless 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

  1. Composable: Rules can be combined using and, or, not
  2. Extensible: Easy to implement custom validation rules
  3. Type-safe: Strongly typed validation for different data types
  4. Informative: Detailed error messages with field locations
  5. Async Support: Async validation for I/O-bound checks
  6. 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§

RiSanitizationConfig
RiSanitizer
RiSchemaValidator
RiValidationError
RiValidationModule
RiValidationResult
RiValidationRunner
RiValidatorBuilder

Enums§

RiValidationSeverity

Traits§

RiValidationRule
RiValidator