JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2383
  • Score
    100M100P100Q123917F
  • License ISC

Extra rules for LIVR Validator

Package Exports

  • livr-extra-rules

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (livr-extra-rules) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

npm version

js-livr-extra-rules

LIVR specification contains the most common rules that every implementation should support.

The module contains extra rules for LIVR. It is absolutely ok for LIVR to have your own custom rules in your project. But there are some rules that are useful cross projects.

import LIVR from livr;
import extraRules from 'livr-extra-rules';
LIVR.Validator.registerDefaultRules(extraRules);

Rules

  • ipv4

ipv4

Example:

{
    field: 'ipv4'
}

Error code: 'WRONG_IP'

How to add own rule?

if you want to add own rule, you will need:

  1. Create a new file for the rule in src/rules (see existing rules)
  2. Add rule to src/index.js
  3. Add positive tests to tests/test_suite/positive/your_rule_name/ (see existing tests)
  4. Add negative tests to tests/test_suite/negative/your_rule_name/ (see existing tests)
  5. Update this README!

Rules TODO

The list of rules that are going to be added here

  • ipv6
  • uuid
  • mongo_object_id
  • base64
  • phone
  • min_iso_date
  • max_iso_date
  • iso_date_between
  • iso_time
  • required_if (check conflict_with)
  • list_length // {list_length: 2}, {list_length: [3, 5]} // list_length_between, list_length_min?
  • credit_card
  • iso_future\ _date