Giter Site home page Giter Site logo

dart-fluent-validation's Introduction

Fluent Validation

This is a port of the C# variant as can be seen at This Link

The goal with this was to decouple the UI validation as seen in Flutters TextFields and use a more common and readable standard. It is still very much beta so please give it a go and give me your feedback.

class UserValidator extends AbstractValidator<User> {
	UserValidator() {
		ruleFor((user) => user.age).isNotNull().greaterThanOrEqual(13);
		ruleFor((user) => user.name).isNotEmpty();
	}
}

// Later on
final UserValidator validator = UserValidator();
ValidationResult result = validator.validate(user);

Features

  1. Built in validators (Most included, as well as some extra ones)
  2. Custom validators (Only supported through the 'must' matcher at the moment)
  3. Localisation (Not done yet)

Built in Validators

  • isNull - (checks the object is null)
  • isNotNull - (checks the object is not null)
  • notEmpty - (checks the object is a String and not empty)
  • empty - (checks the object is a String and is empty)
  • notEqual - (checks if an object is not equal to another)
  • equal - (checks if an object is equal to another)
  • length - (checks the object is a String and is between two other numbers)
  • minLength - (checks the object is a String and is of a minimum length)
  • maxLength - (checks the object is a String and is at least of a maximum length)
  • lessThan - (checks the object is a number and is less than another number)
  • lessThanOrEqual - (checks the object is a number and is less than or equal to another number)
  • greaterThan - (checks the object is a number and is greater than another number)
  • greaterThanOrEqual - (checks the object is a number and is greater than or equal to another number)

Extra Built In Validators

These are not included in the default C# version.

  • isValidEmailAddress - (checks the object is a String and is a valid email address)
  • isValidPhoneNumber - (checks the object is a String and is a valid phone number)
  • isValidNationalInsuranceNumber - (checks the object is a String and is a valid UK national insurance number)
  • isValidUKPostCode - (checks the object is a String and is a valid UK post code)

Contributing

Feel free to do a pull request with any ideas and I will check each one. ¬ Rad

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.