2.1.3 • Published 7 years ago
param-check v2.1.3
param-check
运行时数据校验工具 | a javascript run-time data verification tool.
Install
npm install param-check --saveUsage
Basic usage
import check from 'param-check'
function fn (arg1, arg2) {
check(arg1).isString()
check(arg2, 'arg2').greaterThan(1).lessThan(2)
}Import of specific check
import check from 'param-check/naked'
import isStringCheck from 'param-check/lib/checks/isString'
check.registerCheck(isStringCheck)
function fn (arg) {
check(arg, 'arg').isString()
}Custom check
import check from 'param-check'
import isNumber from 'lodash/isNumber'
function isEven (target, name) {
return isNumber(target) && !(target % 2)
}
check.registerCheck('isEven', isEven)
function fn (arg) {
check(arg, 'arg').isEven()
}Custom linkable check
import check from 'param-check'
import isNumber from 'lodash/isNumber'
function isEven (target, name) {
return isNumber(target) && !(target % 2)
}
function isEventNext (target) {
return return target + 1
}
check.registerCheck('isEven', isEven, isEventNext)
function fn (arg) {
check(arg, 'arg').isEven().isEven() // error occurred
}2.1.3
7 years ago
2.1.2
8 years ago
2.1.1
8 years ago
2.1.0
8 years ago
2.0.0
8 years ago
1.1.9
8 years ago
1.1.8
9 years ago
1.1.7
9 years ago
1.1.5
9 years ago
1.1.4
9 years ago
1.1.3
9 years ago
1.1.2
9 years ago
1.1.1
9 years ago
1.1.0
9 years ago
0.2.6
10 years ago
0.2.5
10 years ago
0.2.4
10 years ago
0.2.3
10 years ago
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.0
10 years ago
