NumberValidator
NumberValidator
Section titled “NumberValidator”Use NumberValidator for quantities, ages, prices, scores, and other numeric fields.
Create a rule
Section titled “Create a rule”Rule::number(string $field): NumberValidatorMethods
Section titled “Methods”| Method | Description |
|---|---|
| `min(int | float $value)` |
| `max(int | float $value)` |
length(int $min, int $max) | Configure inherited length limits when needed. |
required(bool $required = true) | Mark the field as required. |
optional() | Allow a missing value. |
validateField(mixed $value) | Return the first error or null. |
validateFieldAll(mixed $value) | Return every applicable error. |
Example
Section titled “Example”use Fynix\Rule;
$validator = Rule::number('quantity') ->min(1) ->max(1000);
$errors = $validator->validateFieldAll(0);Bounds must be finite numbers. Non-numeric input and values outside the configured range produce validation errors.