简体   繁体   English

无法使用geddy输出自定义验证错误消息

[英]Unable to output custom validation error messages with geddy

I'm using the geddy framework and following the validation examples . 我正在使用geddy框架并遵循验证示例

In my User model I have the following custom validation rule: 在我的用户模型中,我具有以下自定义验证规则:

this.validatesWithFunction('password', function(val) {
    var re = /^[a-z0-9]+$/i;
    return re.test(val)
}, {message: 'must be alphanumeric'})

In my view I do this: 我认为这样做:

<% if(params.err['password']) { %><%=params.err['password'];%><% } %>

The validation rule does work as expected . 验证规则确实按预期工作 However, the message I get back appears to me a generic ("password" is invalid) message rather than the one I have specified in the options ("must be alphanumeric"). 但是,我收到的消息对我来说是通用消息(“密码”无效),而不是我在选项中指定的消息(“必须为字母数字”)。

Any pointers as to where I am going wrong please? 请问关于我要去哪里的任何指示?

This was a bug we just fixed a few days ago. 这是我们几天前刚刚修复的错误。 I'm not sure if it's been pushed to npm yet, but try updating and see if that resolves your problem. 我不确定是否已将其推送到npm,但是尝试更新并查看是否可以解决您的问题。

Update: This should be fixed in npm version 0.9.9 更新:此问题应在npm 0.9.9版中修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM