Don Han
Results
2
comments of
Don Han
> Seriously though, those are terrible instructions. > > When I pasted in the following I got error messages. No explanation at all on what "# your configuration." means. >...
首先添加一个自定义校验规则: 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...