Skip to content
koorchikPublic

About

Language Independent Validation Rules Specification

Resources

Stars

293 stars

Watchers

14 watching

Forks

Repository files navigation

LIVR

Language Independent Validation Rules (v2.5)

Website · Validation rules · Playground · Implementations · Test suite

LIVR is a specification for describing data validation rules as plain data. Write the rules once and validate data the same way, with the same error codes, in JavaScript, Perl, PHP, Python, Go, Erlang and other languages.

{
    name: 'required',
    email: ['required', 'email'],
    gender: { one_of: ['male', 'female'] },
    phone: { max_length: 10 },
    password: ['required', { min_length: 10 }],
    password2: { equal_to_field: 'password' }
}

Try it in the playground →

Validator meets the following requirements

  1. Rules are declarative and language independent
  2. Any number of rules for each field
  3. Validator should return together errors for all fields
  4. Exclude all fields that do not have validation rules described
  5. Possibility to validate complex hierarchical structures
  6. Easy to describe and understand validation
  7. Returns understandable error codes (neither error messages nor numeric codes)
  8. Easy to implement own rules (usually you will have several in every project)
  9. Rules should be able to change results output ("trim", "nested_object", for example)
  10. Multipurpose (user input validation, configs validation, contracts programming etc)
  11. Unicode support

Implementations

Language Repository Package LIVR Maintainer
JavaScript koorchik/js-validator-livr, docs npm: livr 2.5 @koorchik
Perl koorchik/Validator-LIVR CPAN: Validator::LIVR 2.5 @koorchik
PHP WebbyLab/php-validator-livr Packagist: validator/livr 2.0 @WebbyLab
Python asholok/python-validator-livr PyPI: LIVR 2.0 @asholok
Go k33nice/go-livr Go: github.com/k33nice/go-livr 2.0 @k33nice
Java vlbaluk/java-validator-livr Maven Central: io.github.vlbaluk:validator-livr 2.0 @vlbaluk
Ruby fuksito/ruby-livr RubyGems: ruby-livr 2.0 @fuksito
Erlang (Liver) erlangbureau/liver Hex: liver 2.0 @erlangbureau
Erlang (Olifer) Prots/olifer — 2.0 @Prots
Lua fperrad/lua-LIVR LuaRocks: lua-livr 2.0 @fperrad
Raku koorchik/perl6-livr raku.land: LIVR 2.5 @koorchik
Swift olxbr/livr-swift-validator CocoaPods: Livr 2.0 @olxbr
Dart koorchik/dart-livr pub.dev: livr 2.5 @koorchik
Rust koorchik/rust-livr crates.io: livr 2.5 @koorchik

The latest LIVR version is 2.5: it adds rules to 2.0, the previous one (changelog, specification). The version before 2.0 is 0.4. Test suite results for every implementation are on the implementations page.

Documentation

Repository

Directory Content
docs/ The specification website (livr-spec.org), built with VitePress
test_suite/ The test suite that every implementation runs (LIVR 2.0)
test_suite_2.5/ The test suite of the rules added in LIVR 2.5
drafts/ The LIVR 2.5 specification (v2.5.md) and ideas for 3.0
conformance/ Runners that check the published implementations against the test suite

To work on the website: npm install, then npm run docs:dev. See Improve this documentation.

License

Artistic License 2.0

About

Language Independent Validation Rules Specification

Resources

Stars

293 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages