]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * Validates that the length of the value is between a {@link #min} and {@link #max}.\r | |
3 | */\r | |
4 | Ext.define('Ext.data.validator.Length', {\r | |
5 | extend: 'Ext.data.validator.Bound',\r | |
6 | alias: 'data.validator.length',\r | |
7 | \r | |
8 | type: 'length',\r | |
9 | \r | |
10 | config: {\r | |
11 | /**\r | |
12 | * @cfg {Number} min\r | |
13 | * The minimum length value.\r | |
14 | */\r | |
15 | \r | |
16 | /**\r | |
17 | * @cfg {Number} max\r | |
18 | * The maximum length value.\r | |
19 | */\r | |
20 | \r | |
21 | /**\r | |
22 | * @cfg {String} minOnlyMessage\r | |
23 | * The error message to return when the value is less than the minimum\r | |
24 | * length and only a minimum is specified.\r | |
25 | */\r | |
26 | minOnlyMessage: 'Length must be at least {0}',\r | |
27 | \r | |
28 | /**\r | |
29 | * @cfg {String} maxOnlyMessage\r | |
30 | * The error message to return when the value is more than the maximum\r | |
31 | * length and only a maximum is specified.\r | |
32 | */\r | |
33 | maxOnlyMessage: 'Length must be no more than {0}',\r | |
34 | \r | |
35 | /**\r | |
36 | * @cfg {String} bothMessage\r | |
37 | * The error message to return when the value length is not in the specified \r | |
38 | * range and both the minimum and maximum are specified.\r | |
39 | */\r | |
40 | bothMessage: 'Length must be between {0} and {1}'\r | |
41 | },\r | |
42 | \r | |
43 | getValue: function(v) {\r | |
44 | return String(v).length;\r | |
45 | }\r | |
46 | });\r |