pvalidator

Creator: coderz1093

Last updated:

0 purchases

pvalidator Image
pvalidator Images
Add to Cart

Description:

pvalidator

A simple package to validate inputs in flutter.



Features #
Avaliable rules

Accept values: list of accepted values
Date: test with DateTime.tryParse
Email: email validate
Max numeric: check max number
Max string: check max string size
Min numeric: check min number
Min string: check min string size
Numeric: check value is numeric
Regexp: validate with regular expression
Required: check if exist value
Requiredif: check if exist value if
Same: value must be same
Size string: value size check
Minimum date time: parse string and check is date is after the minimum
maximum date time: parse string and check is date is before the maximum
Size string: value size check
Integer: check value is a integer
Only one: check if only one value was entered

packages.yaml #
pvalidator: <lastest version>
copied to clipboard
Usage #
Mandatory field validation example:
TextFormField(
validator: (string) {
return PValidator([
PRuleRequired(string),
]).val();
},
)
copied to clipboard
PValidator is the master class. PRuleRequired is the validate rule. Set one or more rules to validate.
Validate with multiple rules:
TextFormField(
validator: (string) {
return PValidator([
PRuleRequired(string),
PRuleSizeString(string, 5),
]).val();
},
)
copied to clipboard
Create your custom rule
import 'package:pvalidator/src/rules/rule.dart';

class MyCustomRule implements Rule {
String? _value;
String message;

MyCustomRule(this._value, {this.message = "Value must be equal test"});

@override
String? validate() {
if (_value == null || _value?.trim().length == 0) {
return null;
} else if (_value != "test") {
return message;
} else {
return null;
}
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.