lh-validate-form

1.0.0 • Public • Published

ValidateForm

form校验

Usage

install

npm install --save git+https://github.com/liuhong1happy/lh-validate-form.git

quickly start

  // 1. rules
  const rules = [
    new ValidateRule({ field: 'firstName', required: true, msg: 'firstName field is required. '}),
    new ValidateRule({ field: 'lastName', required: true, msg: 'lastName field is required. '}),
  ]
  // 2. validator
  const validator = new Validator(rules);
  
  // 3. validate
  const validateResult = validator.validate(data);

  // 4. result
  if(validateResult.validate) {
    // success
    
  } else {
    // error
    console.log(validateResult.msg);
  }

Readme

Keywords

Package Sidebar

Install

npm i lh-validate-form

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

4.64 kB

Total Files

4

Last publish

Collaborators

  • liuhong1happy