DecimalFieldValidator
class DecimalFieldValidator extends NumericNonStringFieldValidator (View source)
Validates that a value is a valid decimal This intended for use when validating that a value can be stored in a database as a decimal
Example of how digits are stored in the database Decimal(5,2) is allowed a total of 5 digits, and will always round to 2 decimal places This means it has a maximum 3 digits before the decimal point
Valid 123.99 999.99 -999.99 123.999 - will round to 124.00
Not valid 1234.9 - 4 digits the before the decimal point 999.999 - would be rounded to 1000.00 which exceeds 5 total digits
Properties
protected | string | $name | The name of the field being validated |
from FieldValidator |
protected | mixed | $value | The value to validate |
from FieldValidator |
protected | bool | $allowNull | Whether null is considered a valid value |
from FieldValidator |
protected | int|null | $minValue | Minimum size of the number |
from NumericFieldValidator |
protected | int|null | $maxValue | Maximum size of the number |
from NumericFieldValidator |
Methods
No description
Inner validation method that performs the actual validation logic
Details
__construct(string $name, mixed $value, int $wholeSize, int $decimalSize, int|null $minValue = null, int|null $maxValue = null)
No description
ValidationResult
validate()
Validate the value
protected ValidationResult
validateValue()
Inner validation method that performs the actual validation logic
protected string
getTooSmallMessage()
No description
protected string
getTooLargeMessage()
No description