queen_validators 1.0.0-beta
queen_validators: ^1.0.0-beta copied to clipboard
queen support for validation in flutter , functions for variables validation , Rules for Forms with ZERO extra widgets
Queen validators 1👑
#
مقال يشرح بالعربي الفائده من المكتبة وطريقة الاستخدام
Features #
- ✅ Support Null Safety
- ✅ Support all platforms
- ✅ Validate Flutter Forms in vanilla flutter
- ✅ Validate Varibales (each rule have function in same name put in camelCase)
- ❌ Localization
- ✅ easily integrate with any localization solution
- ❌ support Nations out of the box
- ❌ magic rules
IsOptional()
IsRequired()
✊ - ❌ extend the base class
TextValidationRule
and build your own custom rules - ❌ use
.when(WhenCallback)
to make the rule optional base on the callback result 😎 - ❌ use
qValidation(args,onFailureCallBack)
to execute code on specific FromFelid failure 🤘 - ❌ use
QueenValidators.enableLogs()
to enable console Logs 🚧 - ❌ Documentation for each Rule 📃
Get Started #
dependencies:
queen_validators: <latest_version>
Validate Forms #
import 'package/queen_validators/queen_validators.dart';
@override
Widget build(BuildContext context) {
return TextFormField(
// use qValidator function and provider list of rules to apply on this field
validator: qValidator([
IsRequired(),
IsOptional()
IsEmail(),
MinLength(8),
MaxLength(30, "optionally you can override the failure if the validation fails"),
]),
);
}
Validate variables #
const badEmail = 'QueenRoyal.kingdom';
print(isEmail(badEmail)) // false
const validEmail = 'Queen@Royal.kingdom';
print(isEmail(validEmail)) // true
Click to Open Supported Rules List #
NOTES #
- some rules takes the failure message as optional param like
IsDateMilli
TODO #
Colors #
- support hex colors opacity
Rules #
Text #
Rule | Function | Description | trims | Notes |
---|---|---|---|---|
Contains |
❌ | if input contains some some value | ✔ | --------------------------- |
NotContains |
❌ | if input NOT contains the some value | ✔ | --------------------------- |
IsEmpty |
isEmpty(String) |
if input is empty | ✔ | --------------------------- |
IsNotEmpty |
isNotEmpty(String) |
if input is not empty | ✔ | --------------------------- |
IsRequired |
❌ | --------------------------------------- | ✔ | identical with IsNotEmpty |
Match |
match(Object,Object) |
if two inputs is the same type && value | ❌ | --------------------------- |
MaxLength |
❌ | if input length <= max | ✔ | --------------------------- |
MinLength |
❌ | if input length >= min | ✔ | --------------------------- |