formdator 0.4.0 copy "formdator: ^0.4.0" to clipboard
formdator: ^0.4.0 copied to clipboard

outdated

A formidable collection of form field validators that can be selected and grouped into various combinations through composition — Decorator Pattern.

formdator #

EO-Color logo

EO principles respected here DevOps By Rultor.com

pub license PDD status

build codecov CodeFactor Hits-of-Code style: lint

Formidable Validator — Formdator is a fully object-oriented package for validating Flutter form fields. Its key benefits, compared to all other similar packages, include:

  • Object-oriented mindset: there is no static functions, only trustworthy immutable objects.
  • Easy-to-compose validators, e.g., the command Trim(ReqEmail()) produces a validator that trims the entered email and then validates it.
  • You can apply multiple validation rules at once by using the Rules class.
  • Classes with short — yet meaningful — names like Req for a required (non-blank) field; ReqEmail for a non-blank and well-formed email; Len.min for a minimum number of characters.
  • No complex class hierarchy: each validator only implements the Dart's built-in call() method.

For easier integration with the fields of a Flutter form, each validator implements the call() method; therefore, any validator can be treated as an ordinary function.

Getting Started #

A flexible package provides components that can be selected and grouped in various combinations so that user requirements can be fulfilled.

As a demonstration of such combinations of components, the code below shows how you can easily group Trim and Email to form a trimmed-email field with a custom error message in case of a malformed email.

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      onSaved: _onSaved,
      validator: Trim(Email(mal: 'malformed email.')),
      keyboardType: TextInputType.emailAddress,
    );
  }

Demo application #

The demo application provides a fully working example, focused on demonstrating exactly four validators in action — Rules, ReqEmail and Equal. You can take the code in this demo and experiment with it.

To run the demo application:

git clone https://github.com/dartoos-dev/formdator.git
cd formdator/example/
flutter run -d chrome

This should launch the demo application on Chrome in debug mode.

formdator_demo_app

28
likes
0
points
118
downloads

Publisher

verified publisherdartoos.dev

Weekly Downloads

A formidable collection of form field validators that can be selected and grouped into various combinations through composition — Decorator Pattern.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cpf_cnpj_validator, flutter

More

Packages that depend on formdator