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
//表单数据验证规则--controller/uer.js const createRule={ name:{type:'string',required: true, allowEmpty: false,min:5,max:32}, password:{type: 'password', required: true, allowEmpty: false, min: 6}, email:{type: 'email', required: true, allowEmpty: false} }; //对表单数据进行校验 try{ ctx.validate(createRule); } catch(err){ ctx.body=err; return; } 打印出的error: {"message":"Validation Failed","code":"invalid_param","errors":[{"message":"length should bigger than 5","code":"invalid","field":"name"},{"message":"should not be empty","code":"invalid","field":"password"}]}
我想把上面errors中的message改成中文,请问在哪里改呢?或者怎么配置?
The text was updated successfully, but these errors were encountered:
确实需要自定义错误信息.
Sorry, something went wrong.
Parameter 支持 translate,不过 egg-validate 没传
#589
dead-horse
No branches or pull requests
//表单数据验证规则--controller/uer.js
const createRule={
name:{type:'string',required: true, allowEmpty: false,min:5,max:32},
password:{type: 'password', required: true, allowEmpty: false, min: 6},
email:{type: 'email', required: true, allowEmpty: false}
};
//对表单数据进行校验
try{
ctx.validate(createRule);
}
catch(err){
ctx.body=err;
return;
}
打印出的error:
{"message":"Validation Failed","code":"invalid_param","errors":[{"message":"length should bigger than 5","code":"invalid","field":"name"},{"message":"should not be empty","code":"invalid","field":"password"}]}
我想把上面errors中的message改成中文,请问在哪里改呢?或者怎么配置?
The text was updated successfully, but these errors were encountered: