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

  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 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§

DMSCSanitizationConfig
DMSCSanitizer
DMSCSchemaValidator
DMSCValidationError
DMSCValidationModule
DMSCValidationResult
DMSCValidationRunner
DMSCValidatorBuilder

Enums§

DMSCValidationSeverity

Traits§

DMSCValidationRule
DMSCValidator