We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一些可选的参数常常拥有一个默认值,虽然实现并不复杂,但这无疑增加了代码的复杂程度,也不够优雅。
基于此,设想一下默认值方法的基本使用:
const [ foo ] = await acr.validate({}, { foo: acr.string().default('bar'), }); foo; // 'bar';
嗯,实现了功能,但不够强大,如果这个默认值可能会基于其它参数的值来确定呢?
const [ foo ] = await acr.validate({ bax: 123, }, { foo: acr.string().default((data, context) => { return data['bax'] === 123 ? 'bar' : 456; }), }); foo; // 'bar';
这样应该算实现了一个完整的默认值功能。
The text was updated successfully, but these errors were encountered:
feat: 支持默认值 #2
542a3c9
Merge pull request #4 from seekcx/default-value
41eb790
No branches or pull requests
一些可选的参数常常拥有一个默认值,虽然实现并不复杂,但这无疑增加了代码的复杂程度,也不够优雅。
基于此,设想一下默认值方法的基本使用:
嗯,实现了功能,但不够强大,如果这个默认值可能会基于其它参数的值来确定呢?
这样应该算实现了一个完整的默认值功能。
The text was updated successfully, but these errors were encountered: