O2YO.FluentValidation 0.0.2 License Info

O2YO.FluentValidation 0.0.2

O2YO.FluentValidation

Overview

O2YO.FluentValidation is a powerful and flexible validation library for C# applications, allowing developers to define and execute validation rules in a fluent and intuitive manner. With support for asynchronous operations and a wide range of validation methods, O2YO.FluentValidation simplifies the task of validating data in .NET projects.

Features

  • Fluent Validation: Define validation rules using fluent syntax for cleaner and more readable code.
  • Asynchronous Support: All validation methods support asynchronous operations, ensuring improved performance and responsiveness in applications.
  • Comprehensive Validation Rules: Includes a wide range of validation methods for common scenarios, such as checking for null, emptiness, equality, length constraints, numeric comparisons, credit card numbers, mobile numbers, special characters, spaces, alphabetic characters, and email addresses.
  • Compatibility: Compatible with .NET Standard and .NET Core environments, ensuring seamless integration into existing projects.

Benefits

  • Simplicity: Simplifies the task of implementing validation logic with an intuitive API and fluent syntax.
  • Performance: Asynchronous support ensures efficient validation operations, especially in scenarios involving I/O-bound tasks.
  • Consistency: Enforces consistent validation practices across projects, ensuring data integrity and reliability.
  • Flexibility: Offers a wide range of validation methods to accommodate various validation requirements without the need for custom implementations.
  • Maintainability: Clean and readable codebase enhances maintainability and reduces the likelihood of errors.

Author

O2YO.FluentValidation is developed and maintained by Shafi Hussain, a seasoned software developer with over 20 years of experience in the industry. With a proven track record of delivering high-quality software solutions, Shafi brings a wealth of expertise to the development of O2YO.FluentValidation.

Available Methods

The following validation methods are available in O2YO.FluentValidation:

  • NotEmptyAsync: Validates that a property is not null or empty.
  • NotNullAsync: Validates that a property is not null.
  • NotEqualToAsync: Validates that a property is not equal to a specified value.
  • EqualToAsync: Validates that a property is equal to a specified value.
  • LengthInRangeAsync: Validates that the length of a string property or the count of a collection property falls within a specified range.
  • MaxLengthAsync: Validates that the length of a string property or the count of a collection property does not exceed a specified maximum.
  • MinLengthAsync: Validates that the length of a string property or the count of a collection property meets or exceeds a specified minimum.
  • LessThanAsync: Validates that a numeric property is less than a specified threshold.
  • LessThanOrEqualToAsync: Validates that a numeric property is less than or equal to a specified threshold.
  • GreaterThanAsync: Validates that a numeric property is greater than a specified threshold.
  • GreaterThanOrEqualToAsync: Validates that a numeric property is greater than or equal to a specified threshold.
  • CreditCardAsync: Validates that a string property represents a valid credit card number.
  • MobileNumberAsync: Validates that a string property represents a valid 10-digit mobile number.
  • SpecialCharacterAsync: Validates that a string property does not contain any special characters.
  • SpaceOnlyAsync: Validates that a string property contains only spaces.
  • NoSpaceAsync: Validates that a string property does not contain any spaces.
  • IsAlphabateAsync: Validates that a string property contains only alphabetic characters and spaces.
  • EmailAsync: Validates that a string property represents a valid email address.

Usage

// Example usage of validation rules
var validator = new O2YOValidate<UserModel>(user, new List<string>());
await validator.NotEmptyAsync(x => x.Name);
await validator.EmailAsync(x => x.Email);
// Add more validation rules as needed

```csharp
// Example usage of validation rules with chained methods
var validator = new O2YOValidation<UserModel>(user, new List<string>());
await validator.NotEmptyAsync(x => x.Name)
    .NotNullAsync(x => x.Email)
    .NotEqualToAsync(x => x.Role, UserRole.Admin)
    .EqualToAsync(x => x.Status, UserStatus.Active)
    .LengthInRangeAsync(x => x.Address, 5, 100)
    .MaxLengthAsync(x => x.Description, 500)
    .MinLengthAsync(x => x.Password, 8)
    .LessThanAsync(x => x.Price, 100.00)
    .LessThanOrEqualToAsync(x => x.Quantity, 10)
    .GreaterThanAsync(x => x.Score, 75)
    .GreaterThanOrEqualToAsync(x => x.Age, 18)
    .CreditCardAsync(x => x.CreditCardNumber)
    .MobileNumberAsync(x => x.PhoneNumber)
    .SpecialCharacterAsync(x => x.SpecialField)
    .SpaceOnlyAsync(x => x.SpaceField)
    .NoSpaceAsync(x => x.NoSpaceField)
    .IsAlphabateAsync(x => x.AlphabateField)
    .EmailAsync(x => x.EmailField);
// Add more validation rules as needed


### Contributions

Contributions to O2YO.FluentValidation are welcome! If you encounter any issues, have suggestions for improvements, or would like to contribute to the project, please feel free to open GitHub issues or submit pull requests.

### License

This project is licensed under the MIT License - see the LICENSE file for details.

Thank you for choosing O2YO.FluentValidation! We hope this library helps simplify and streamline your validation processes in C# projects. If you have any questions or feedback, please don't hesitate to reach out to us.