Ow函数参数验证

联合创作 · 2023-09-22

为人类设计的的函数参数验证。

特性

  • 富有表现力的可链接 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`
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报