Expand description
Validation utilities for input validation and data sanitization Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
This file is part of DMSC. The DMSC 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 DMSC, including input validation, schema validation, and data verification. It supports various validation rules and provides detailed error messages.
§Key Components
- DMSCValidator: Core validation trait
- DMSCValidationRule: Individual validation rule
- DMSCValidationResult: 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 dmsc::validation::{Validator, ValidationRule, DMSCValidator};
use dmsc::prelude::*;
let validator = DMSCValidator::new("user_email")
.not_empty()
.is_email()
.max_length(255);
let result = validator.validate("test@example.com");
assert!(result.is_valid());Structs§
- DMSC
Sanitization Config - DMSC
Sanitizer - DMSC
Schema Validator - DMSC
Validation Error - DMSC
Validation Module - DMSC
Validation Result - DMSC
Validation Runner - DMSC
Validator Builder