Skip to content

SyncedPSI/value-validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

value-validate

npm

Verify that a value matches the rules.

###Install

$ npm install value-validate --save
# or
$ yarn add value-validate

###Usage

import { validation } from 'value-validate';

/**
 *
 * @param  {String}         value   String that need to be validated
 * @param  {Object|String}  rules   Validation rules
 */

validation(
  'cedcn@qq.com',
  ['required', { type: 'email', msg: 'Please input the correct email format!'}],
  result => console.log(result);
);

####Rules

  • required
  • email
  • phone
  • number
  • number-gt-#{number}
  • number-lt-#{number}
  • number-gts-#{number}
  • number-lts-#{number}
  • count-gts-#{value}
  • count-lts-#{value}

####Callback

retrun { isPass: [Bool], mag: [String] }

Releases

No releases published

Packages

No packages published