fluent_validation_flutter 0.0.6
fluent_validation_flutter: ^0.0.6 copied to clipboard

Flutter Android iOS web

FluentValidationFlutter is strongly inspired by FluentValidation for C# and is intended to bring Dart a similar experience.

FluentValidationFlutter #

A small Flutter package for building validation rules.

Getting Started #

This project was forked from flutter_validate (which has not been updated for a long time) and with some ideas from fluent_validation, has been updated and added some changes to make it more like using FluentValidation .NET

Simple Example #

class CustomerValidator extends AbstractValidator<Customer> {
  CustomerValidator() {
    ruleFor("id", (customer) => customer.id).notNull();
    ruleFor("name", (customer) => customer.name).notEmpty();
    ruleFor("age", (customer) => customer.age).greaterThan(18);
  }
}

Customer customer = Customer();
CustomerValidator validator = new CustomerValidator();
validator.validate(customer);
bool isValid = validator.isValid();
List<String> errors = validator.allErrors;

Complex Example #

class CustomerValidator extends AbstractValidator<Customer> {
  CustomerValidator() {
    ruleFor("id", (customer) => customer.id)..notNull()..greaterThan(0);;
    ruleFor("name", (customer) => customer.name)
    ..notEmpty()..notEqual(() => "Squall");;
    ruleFor("age", (customer) => customer.age)
    ..greaterThan(18)..withMessage("Custom Message");
  }
}

Customer customer = Customer();
CustomerValidator validator = new CustomerValidator();
validator.validate(customer);
bool isValid = validator.isValid();
List<String> errors = validator.allErrors;

Built-in Validators #

  • NotNull Validator
  • NotEmpty Validator
  • NotEqual Validator
  • Equal Validator
  • Length Validator
  • MaxLength Validator
  • MinLength Validator
  • LessThan Validator
  • LessThanOrEqualTo Validator
  • GreaterThan Validator
  • GreaterThanOrEqualTo Validator
  • Matches Validator
  • Must Validator
  • Empty Validator
  • EmailAdress Validator

Credits #

Forked from flutter_validate repo.

fluent_validation repo.

1
likes
100
pub points
25%
popularity

FluentValidationFlutter is strongly inspired by FluentValidation for C# and is intended to bring Dart a similar experience.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

evertonrps@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on fluent_validation_flutter