A simple library for data validation.
Validation Lib can be installed using one of these commands
PM> Install-Package ValidatorLib
> dotnet add package ValidatorLib
Tests and benchmarks can be found in /src/tests/
var str = "[email protected]";
try
{
Validator.Validate(str).IsEmailAddress();
Validator.Validate(str).MinLength(8);
Validator.Validate(str).IsNotEmpty();
}
catch (ArgumentException e)
{
// If an exception is thrown, the string is not valid
}
var str = "[email protected]";
try
{
var validator = new CustomValidator<string>();
validator.AddRule(x => Validator.Validate(x).IsEmailAddress());
validator.AddRule(x => Validator.Validate(x).MinLength(8));
validator.AddRule(x => Validator.Validate(x).IsNotEmpty());
validator.Validate(str);
}
catch (ArgumentException e)
{
// If an exception is thrown, the string is not valid
}
For more examples let's see /examples/
For support, email [email protected]
If you have any feedback, please reach out to me at [email protected]
Contributions are always welcome!
Remember to edit README.md and documentation.md
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes