diff options
| author | Asko Nomm <asko@bien.ee> | 2022-02-22 21:32:37 +0100 |
|---|---|---|
| committer | Asko Nomm <asko@bien.ee> | 2022-02-22 21:32:37 +0100 |
| commit | b0fd14cd71d60c1b9926aff10fe9e8eeebe1285c (patch) | |
| tree | ff5f1689ffa87a84d8c7487d8a64c885ce7b592e /src/Validators.php | |
| parent | 4256c45b6b9c96400b8f372b289be1127495ac56 (diff) | |
Lots of documentation and basic tests
Diffstat (limited to 'src/Validators.php')
| -rw-r--r-- | src/Validators.php | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/Validators.php b/src/Validators.php deleted file mode 100644 index 0040657..0000000 --- a/src/Validators.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php - -namespace Askonomm\Validator; - -/** - * Undocumented class - */ -class Validators -{ - /** - * Undocumented function - * - * @return array - */ - public static function len(): array - { - return [ - 'error' => 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; - } - ]; - } - - /** - * Undocumented function - * - * @return array - */ - 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; - } - ]; - } - - /** - * Undocumented function - * - * @return array - */ - public static function required(): array - { - return [ - 'error' => function (string $field): string { - return "${field} is required."; - }, - 'validates' => function (string $value): bool { - return isset($value) && $value !== ''; - } - ]; - } -} |
