Dón*_*nal 6 grails grails-validation
在Grails应用程序的messages.properties文件中,我看到了验证消息的示例,例如:
User.password.size=Size of bar must be between {0} and {1}
Run Code Online (Sandbox Code Playgroud)
适用于
class User {
String password
static constraints = {
password(size:5..15)
}
}
Run Code Online (Sandbox Code Playgroud)
此示例假定{0}绑定到最小大小,{1}绑定到最大大小,但我找不到任何文档,说明每个内置约束的错误消息可能使用哪些参数.换句话说,我想知道的是:对于每个内置约束,{0}的含义是什么...... {n}
我做了一些实验,我发现了一个约束,例如:
class User {
String password
static constraints = {
password(size:5..15)
}
}
Run Code Online (Sandbox Code Playgroud)
占位符的值为:
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.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2186 次 |
最近记录: |