-
Notifications
You must be signed in to change notification settings - Fork 2
Numeric
Validates the input (mixed
) to be a float or a string representing a float.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\FloatType;
(new FloatType())->validate('12.5');
-
Numeric.FloatType
when the value does not represent a float
Validates the input (mixed
) to be an integer or a string representing an integer.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\Integer;
(new Integer())->validate('12');
-
Numeric.Integer
when the value does not represent an integer
Validates the input (numeric
) to be smaller than or exactly the maximum value (float
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\Maximum;
(new Maximum(16))->validate('12');
-
Numeric.NumericType
when the value is not a numeric type -
Numeric.Maximum
when the value is greater than maximum
Validates the input (numeric
) to be greater than or exactly the minimum value (float
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\Minimum;
(new Minimum(9))->validate('12');
-
Numeric.NumericType
when the value is not a numeric type -
Numeric.Minimum
when the value is smaller than minimum
Validates the input (numeric
) to be a negative value. A value is being considered negative when it is smaller than zero (0
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\Negative;
(new Negative())->validate(-1);
-
Numeric.NumericType
when the value is not a numeric type -
Numeric.Negative
when the value is smaller than zero
Validates the input (mixed
) to be a numeric type.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\NumericType;
(new NumericType())->validate(1200);
-
Numeric.NumericType
when the value is not a numeric type
Validates the input (numeric
) to be a positive value. A value is being considered positive when it is greater than or equal to zero (0
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\Positive;
(new Positive())->validate(1);
-
Numeric.NumericType
when the value is not a numeric type -
Numeric.Positive
when the value is greater than or equal to zero
Validates the input (numeric
) to be within the defined range (numeric
, numeric
) inclusive.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Numeric\Range;
(new Range(10, 200))->validate(38);
-
Numeric.NumericType
when the value is not a numeric type -
Numeric.Minimum
when the value is smaller than minimum -
Numeric.Maximum
when the value is greater than maximum