Ow函数参数验证
为人类设计的的函数参数验证。
特性
-
富有表现力的可链接 API
-
大量内置验证
-
支持自定义验证
-
用 TypeScript 编写
使用
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`评论
