参数化Grails验证消息

参数化Grails验证消息,grails,grails-validation,Grails,Grails Validation,在Grails应用程序的messages.properties文件中,我看到了验证消息的示例,例如: User.password.size=Size of bar must be between {0} and {1} 适用于 class User { String password static constraints = { password(size:5..15) } } 本例假设{0}绑定到最小大小,{1}绑定到最大大小,但我找不到任何文档,

在Grails应用程序的messages.properties文件中,我看到了验证消息的示例,例如:

User.password.size=Size of bar must be between {0} and {1}
适用于

class User {

    String password
    static constraints = {
        password(size:5..15)
    }
}

本例假设{0}绑定到最小大小,{1}绑定到最大大小,但我找不到任何文档,其中的参数可能会被每个内置约束的错误消息使用。换句话说,我想知道的是:对于每个内置约束,{0}的含义是什么……{n}

你是对的,我也没有找到任何关于这方面的文档。最佳选择?将您的邮件更改为以下内容:

User.password.size=0:{0}, 1:{1}, 2:{2}, etc...
看看你对每一件感兴趣的东西都有什么收获。如果您将该信息发布到Grails上的Nabble留言板上,我相信它会进入文档


祝你好运。

我做了一些实验,发现对于以下约束:

class User {    
    String password
    static constraints = {
        password(size:5..15)
    }
}
占位符的值为:

 0. Name of the class (User)
 1. Name of the property (password)
 2. Value of the property
 3. First constraint parameter (5)
 4. Second constraint parameter (15)
 5. etc.

类[{1}]的default.blank.message=Property[{0}]不能为空