The NumberValidator class ensures that a String represents a valid number.
It can ensure that the input falls within a given range
(specified by minValue
and maxValue
),
is an integer (specified by domain
),
is non-negative (specified by allowNegative
),
and does not exceed the specified precision
.
The validator correctly validates formatted numbers (e.g., "12,345.67")
and you can customize the thousandsSeparator
and
decimalSeparator
properties for internationalization.
Static methods
staticvalidateNumber(validator:NumberValidator, value:Dynamic, baseField:String):Array<ValidationResult>
Convenience method for calling a validator from within a custom validation function. Each of the standard Flex validators has a similar convenience method.
Parameters:
validator | The NumberValidator instance. |
---|---|
value | A field to validate. |
baseField | Text representation of the subfield
specified in the |
Returns:
An Array of ValidationResult objects, with one ValidationResult object for each field examined by the validator.
See also:
Constructor
Variables
decimalPointCountError:String
Error message when the decimal separator character occurs more than once.
decimalSeparator:String
The character used to separate the whole
from the fractional part of the number.
Cannot be a digit and must be distinct from the
thousandsSeparator
.
domain:String
Type of number to be validated.
Permitted values are "real"
and "int"
.
In Haxe, you can use the following constants to set this property:
NumberValidatorDomainType.REAL
or
NumberValidatorDomainType.INT
.
integerError:String
Error message when the number must be an integer, as defined
by the domain
property.
invalidFormatCharsError:String
Error message when the value contains invalid format characters, which means that it contains a digit or minus sign (-) as a separator character, or it contains two or more consecutive separator characters.
negativeError:String
Error message when the value is negative and the
allowNegative
property is false
.
precision:Int
The maximum number of digits allowed to follow the decimal point.
Can be any nonnegative integer.
Note: Setting to 0
has the same effect
as setting domain
to "int"
.
A value of -1 means it is ignored.
precisionError:String
Error message when the value has a precision that exceeds the value defined by the precision property.
thousandsSeparator:String
The character used to separate thousands
in the whole part of the number.
Cannot be a digit and must be distinct from the
decimalSeparator
.