FP-Validation
fp-validation
is a FP like validation library, it can let you compose validation function. It's inspired by compose
.
Install
npm install fp-validation
Test
npm test
Usage
Require fp-validation
;;
You can pass a single lib as parameter:
const isNum = ;; // => "Is not a Number"; // => false
You can also pass multiple libs as parameters:
Will apply all libs from right to left.
const isNumIsReq = ;; // => "The value cannot empty"; // => "Is not a Number" // => false
API
vailCompose(libs)
libs
Type: function
Return: If all the validation of the libs are true will be false
otherwise is string
(reason).
The libs you want to compose.
libs
isRequired([reason])
Default: 欄位為必填
isNumber([reason])
Default: 輸入內容必須為數字
isEmail([reason])
Default: 電子信箱格式不正確
maxLength(length, [reason])
Default: 超過最大限制長度
length
字元
minLength(length, [reason])
Default: 小於最小限制長度
length
字元
maxNum(max, [reason])
Default: 數值超過
max
LICENSE
MIT