Kensho

The JavaScript validation library.

What it can do

  • It can validates values simply.

  • It can also validates input values in a form.

  • You can add your own validation rules.

  • It provides any plugins. And you can also add your own plugins.

  • IE 11 support.

Install

NPM

$ npm install @yokotak0527/kensho

CDN

<script src="https://cdn.jsdelivr.net/npm/@yokotak0527/kensho@2.0.1/dist/bundle.umd.min.js"></script>

Please change the version @x.x.x of the URL as you see fit. When using UMD, Kensho is yokotak0527.Kensho.

const Kensho = window.yokotak0527.Kensho;

Validation

In Kensho, It defines a validation function that called: "rule", and validates a value using that, via Kensho.validate() method.

Kensho.validate('email', 'private@myhost.com') // -> true
// The rule is: "email"
// The value that you want to validate is 'private@myhost.com'

Some rules allow you to set options.

Kensho.validate('regexp', 'hello', { "regexp" : /llo$/ }) // -> true

The type of option is always Object . What option properties each rule has, refer to the rule document.

Last updated