0.1.0 • Published 3 years ago

wali v0.1.0

Weekly downloads
5
License
ISC
Repository
-
Last release
3 years ago

业务字段校验

  • 模块说明

    • pattern.js 定义通用规则
    • Rule.js 定义校验函数
    • ruleConf 定义字段校验配置
  • 使用方法

import validator from 'sm-validator'
import pattern from 'sm-validator/pattern'

const regs = pattern.regs

// 配置规则
validator.extendRules({
    name: {
        name: '姓名',
        minByteLength: {
            value: 6,
            message: '{{name}}不能少于{{value}}个字符'
        },
        patterns: [
            {match: regs.cnNameText, message: '{{name}}包含非法字符'},
            {exclude: regs.exCnNameText, message: '{{name}}包含非法字符'}
        ]
    }
})

// 校验

let info = validator.check('name', '周星期')
if (info !== true) {
    // info 可能包含多个校验错误信息
    console.dir(info)
}
0.1.0

3 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

7 years ago