| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class FormValidators |
| 4 |
* |
| 5 |
* @package Packetery\Module |
| 6 |
*/ |
| 7 |
|
| 8 |
declare(strict_types=1); |
| 9 |
|
| 10 |
namespace Packetery\Module; |
| 11 |
|
| 12 |
use Packetery\Nette\Forms\Controls\BaseControl; |
| 13 |
|
| 14 |
/** |
| 15 |
* Class FormValidators |
| 16 |
* |
| 17 |
* @package Packetery\Module |
| 18 |
*/ |
| 19 |
class FormValidators { |
| 20 |
|
| 21 |
/** |
| 22 |
* Tests if input value is greater than argument. |
| 23 |
* |
| 24 |
* @param BaseControl $input Form input. |
| 25 |
* @param float $arg Validation argument. |
| 26 |
* |
| 27 |
* @return bool |
| 28 |
*/ |
| 29 |
public static function greaterThan( BaseControl $input, float $arg ): bool { |
| 30 |
return $input->getValue() > $arg; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Tests if input date is later than argument date |
| 35 |
* |
| 36 |
* @param BaseControl $input Form input. |
| 37 |
* @param string $date Validation argument. |
| 38 |
* |
| 39 |
* @return bool |
| 40 |
*/ |
| 41 |
public static function dateIsLater( BaseControl $input, string $date ): bool { |
| 42 |
return strtotime( $input->getValue() ) > strtotime( $date ); |
| 43 |
} |
| 44 |
} |
| 45 |
|