-
Notifications
You must be signed in to change notification settings - Fork 24
@Digits
vivin edited this page Jul 19, 2012
·
1 revision
@Digits
enforces the constraint that the integer portion of the value of the input element must have up to a certain number of specified digits, and the fractional portion of the value of the input element must have up to another number of specified digits.
Syntax for @Digits
is:
@Digits(integer=integer-value,
fraction=fraction-value, [label=label-text],
[message=message-text],
[groups=array-of-group-names])
Name | Type | Required | Description |
---|---|---|---|
integer |
Integer | yes | A required parameter that specifies the maximum-acceptable number of digits in the integer portion of the value of the input field. |
fraction |
Integer | yes | A required parameter that specifies the maximum-acceptable number of digits in the fractional portion of the value of the input field. |
label |
String | no | An optional parameter that specifies the label for this input element. Labels are a way to provide friendly names to input elements. If the constraint fails to validate, the value in this field will be used in the default error message. If the constraint has a custom error message which contains {label} , the value of this parameter will be substituted in the place of {label} . |
message |
String | no | An optional parameter that specifies the error message to use when this constraint fails. The value for this field can contain interpolations of parameters used by the constraint . For example: {label} needs to be between {min} and {max} . |
groups |
Array | no | An array of group names that specifies the validation groups that this constraint belongs to. |
<input id = "price"
name = "price"
type = "text"
data-constraints = '@Digits(integer=3, fraction=2)' />
<input id = "price"
name = "price"
type = "text"
data-constraints = '@Digits(integer=3, fraction=2,
label="age",
message="The price can have only up to {integer} digits in the integer portion and {fraction} digits in the fractional portion.,
groups=[FirstGroup, SecondGroup, ThirdGroup]"' />