From 4256c45b6b9c96400b8f372b289be1127495ac56 Mon Sep 17 00:00:00 2001 From: Asko Nomm Date: Tue, 22 Feb 2022 18:32:14 +0100 Subject: Swap rules and validators, makes more sense now --- src/ValidatorRules.php | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/ValidatorRules.php (limited to 'src/ValidatorRules.php') diff --git a/src/ValidatorRules.php b/src/ValidatorRules.php deleted file mode 100644 index d3599e0..0000000 --- a/src/ValidatorRules.php +++ /dev/null @@ -1,50 +0,0 @@ - function (string $field, mixed $modifier = 0): string { - return "{$field} is shorter than the required ${modifier} characters."; - }, - 'validates' => function (string $value, mixed $modifier = 0): bool { - if (!isset($value) || strlen($value) < (int) $modifier) { - return false; - } - - return true; - } - ]; - } - - public static function email(): array - { - return [ - 'error' => function (string $field): string { - return "${field} is not a valid e-mail address."; - }, - 'validates' => function (string $value): bool { - if (!isset($value) || !filter_var($value, FILTER_VALIDATE_EMAIL)) { - return false; - } - - return true; - } - ]; - } - - public static function required(): array - { - return [ - 'error' => function (string $field): string { - return "${field} is required."; - }, - 'validates' => function (string $value): bool { - return isset($value) && $value !== ''; - } - ]; - } -} -- cgit v1.2.3