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 rule = { title: 'myRule' }; let r = ctx.validate(rule, ctx.request.body); r 一直是undefined
The text was updated successfully, but these errors were encountered:
首先添加一个自定义校验规则: app.validator.addRule(type, (rule, value) => {...}) 注意这里面的type,我被坑了很久,按照你的例子,type应该是myRule 然后就是校验: const rule = { title: {type: 'myRule'} }; let r = ctx.validate(rule, ctx.request.body); 这种方式没有返回值 可以用try catch try { ctx.validate(rule, ctx.request.body) } catch (error) { ... }
Sorry, something went wrong.
No branches or pull requests
不好意思,实在没看明白自定义规则如何使用。
const rule = { title: 'myRule' };
let r = ctx.validate(rule, ctx.request.body);
r 一直是undefined
The text was updated successfully, but these errors were encountered: