函数参数验证 Ow
- 授权协议: MIT
- 开发语言: JavaScript TypeScript
- 操作系统: 跨平台
- 软件首页: https://github.com/sindresorhus/ow
- 软件文档: https://github.com/sindresorhus/ow/blob/master/readme.md
- 官方下载: https://github.com/sindresorhus/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`
