-
Notifications
You must be signed in to change notification settings - Fork 2
Age
Pieter Hordijk edited this page Dec 30, 2018
·
1 revision
Validates the input (instance of a \DateTimeInterface
) to be an exact match of the age (int
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Age\Exact;
(new Exact(18))->validate(new \DateTimeImmutable('2018-12-13'));
-
Type.InstanceOfType
when the validated value is not an instance of\DateTimeInterface
-
Age.Minimum
when the validated value is less than the target value as defined in the constructor -
Age.Maximum
when the validated value is more than the target value as defined in the constructor
Validates the input (instance of a \DateTimeInterface
) to be younger or exactly the maximum age (int
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Age\Maximum;
(new Maximum(18))->validate(new \DateTimeImmutable('2018-12-13'));
-
Type.InstanceOfType
when the validated value is not an instance of\DateTimeInterface
-
Age.Maximum
when the validated value is more than the target value as defined in the constructor
Validates the input (instance of a \DateTimeInterface
) to be older or exactly the minimum age (int
).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Age\Minimum;
(new Minimum(18))->validate(new \DateTimeImmutable('2018-12-13'));
-
Type.InstanceOfType
when the validated value is not an instance of\DateTimeInterface
-
Age.Minimum
when the validated value is less than the target value as defined in the constructor
Validates the input (instance of a \DateTimeInterface
) to be within range of minimum age (int
) and maximum age (int
) inclusive.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Age\Range;
(new Range(18, 65))->validate(new \DateTimeImmutable('2018-12-13'));
-
Type.InstanceOfType
when the validated value is not an instance of\DateTimeInterface
-
Age.Minimum
when the validated value is less than the minimum age as defined in the constructor -
Age.Maximum
when the validated value is more than the maximum age as defined in the constructor