enterprise_validator 0.0.3
enterprise_validator: ^0.0.3 copied to clipboard
A package which have built in injectable validations, and enables you to create your own.
This package aims to simplify the process of injecting validation rules, to your form fields, taking the single responsibility from SOLID Design pattern, Each class of validation represents a validation rule, which can be applied to your inputs. also you can implement your own validation rules.
Features #
- Provide about 14 built-in validations
- Strings
- Validating email
- Validating json
- Validating required
- Validating length (Min, Max, Exact)
- Validating Mobile Phones (Egyptian, Saudi)
- Numbers
- Validating Equal to
- Validating Not Equal to
- Validating Not Equal to Zero
- Validating Range Of
- Strings
Getting started #
import 'package:enterprise_validator/enterprise_validator.dart'
Usage #
// Orders of validation matters, the first rule you add, the first validation fires.
Column(
children: [
FormField(
validator: (value)=> [
IsRequiredRule('Validation Error Message'),
IsEmailOrMobileRule('Validation Error Message')
].getValidationErrorMessage(value),
),
FormField(
validator: (value)=> [
IsValidRequiredRule('Validation Error Message'),
IsMinimumLengthRule('Validation Error Message', minimum: 15)
].getValidationErrorMessage(value),
),
),
],
);
Additional information #
- This package is still in its initial stage, which means, it may have break changes.
- This package is a personal attempt to make the process of validation easier, it is open source, you can get the code and add your own custom logic.
- It's open to contribute and contact with me for any future improvements for the package.