Powerful Javascript Object Validator
Straints allows for declarative validation rules managed from a single file.
Its aim is to provide easy configuration and maintenance of validation rules across a web or server application.

create_user:
  constrain:
    email: exists, email
    username: exists, string
    password: exists, not.shorter!8
    passwordConfirm:
      - exists
      - { test: equals, param: _.password }
Features
  • Reusable validation contexts and constraint configurations
  • Validate object properties against each other
  • Validate nested objects or nested arrays of objects
  • Conditional context and constraint validation
  • Validate against aggregate validation results
  • Plug-in alternate validator implementation(s)
  • Promise-based async validation methods supported
Get Straints

NPM npm install straints --save

Standalone App Bundles (via unpkg) straints.js straints.min.js