1.0.22 • Published 3 years ago

ty-light-validate v1.0.22

Weekly downloads
63
License
-
Repository
-
Last release
3 years ago

特扬前端轻量级validate库

使用

1.安装

npm install -save-dev ty-light-validate

2.使用

import

import Validate from 'ty-light-validate'

require

const Validate = require('ty-light-validate')

使用

const validater =new Validate();
/**自定义验证规则**/
validater.addRule('ruleName',(value)=>{});
/**验证**/
let demo='lmw';
validater.add(demo,[
  {type:'required',error:'不能为空'},
  {type:'length',error:'最大长度不能超过2位',length:2}
]);
/**执行验证**/
let error=validater.run();
if(error){//不验证通过
  
}else{//验证通过
  
}

自带验证规则

  • required 必填
{type:'required',error:''}
  • length 最大长度不能超过规定长度
{type:'length',error:'',length:4}
  • isNumber 数字
{type:'isNumber',error:''}
  • isMobile 手机号
{type:'isMobile',error:''} 
  • isRealYear 年份(1900--当前)
{type:'isRealYear',error:''}
  • isRealBirthday 有效的出生日期
{type:'isRealBirthday',mode:0}
 mode 0 日期格式 YYYYMMDD
 mode 1 日期格式 YYYY-MM-DD
  • isIdCard 大陆居民身份证验证
{type:'isIdCard',error:''}
1.0.22

3 years ago

1.0.21

4 years ago

1.0.19

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.14

6 years ago

1.0.15

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago