ts-rules Typescript JSON 验证工具 项目简介
Typescript JSON 验证工具,主要设计来验证复杂的约束需求。安装npm install ts-rules --save使用es6 importimport {rules} from 'ts-rules';示例 let r = rules({
p1: 'required | maxLen: 5',
p2: 'eq: {{p1}}'
});
let result = r({
p1: '123456',
p2: ''
});
result.valid; //false
result = r({
p1: '12345',
p2: '12345'
});
result.valid; //true
p1: 'required | maxLen: 5',
p2: 'eq: {{p1}}'
});
let result = r({
p1: '123456',
p2: ''
});
result.valid; //false
result = r({
p1: '12345',
p2: '12345'
});
result.valid; //true