validation-unchained

JSON object validation

Usage no npm install needed!

<script type="module">
  import validationUnchained from 'https://cdn.skypack.dev/validation-unchained';
</script>

README

JSON Validation

Example

const validate = require('validation-unchained');

const { errors, data } = model.validate({
  username: 'chris',
  password: 'pass'
}, {
  strict: true,
  rules: {
    username: { type: String },
    password: { type: String, length: { min: 6, max: 255, inclusive: true } }
  }
});
console.log(errors);
// => { password: [ 'Must be between 6 and 255 characters long.' ] }

Features

  1. Type Conversion
    1. Boolean
    2. Date
    3. Number
    4. String
  2. Strict enforcement
  3. Array Values
  4. All Types
    1. Required
  5. Boolean Validation
  6. Date Validation
  7. Number Validation
    1. Min values
    2. Max values
  8. String Validation
    1. Required values
    2. String lengths
    3. Regular Expression
  9. Custom Validation [WIP]