Ow函數(shù)參數(shù)驗(yàn)證
為人類(lèi)設(shè)計(jì)的的函數(shù)參數(shù)驗(yàn)證。
特性
-
富有表現(xiàn)力的可鏈接 API
-
大量?jī)?nèi)置驗(yàn)證
-
支持自定義驗(yàn)證
-
用 TypeScript 編寫(xiě)
使用
import ow from 'ow';
const unicorn = input => {
ow(input, ow.string.minLength(5));
// …
};
unicorn(3);
//=> ArgumentError: Expected argument to be of type `string` but received type `number`
unicorn('yo');
//=> ArgumentError: Expected string to have a minimum length of `5`, got `yo`評(píng)論
圖片
表情
