Skip to content

Commit 7a9587b

Browse files
committed
Validators: grouped & sorted $validators
1 parent b1fa400 commit 7a9587b

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/Utils/Validators.php

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,47 @@ class Validators
2020
use Nette\StaticClass;
2121

2222
protected static $validators = [
23+
// PHP types
24+
'array' => 'is_array',
2325
'bool' => 'is_bool',
2426
'boolean' => 'is_bool',
27+
'float' => 'is_float',
2528
'int' => 'is_int',
2629
'integer' => 'is_int',
27-
'float' => 'is_float',
28-
'number' => [__CLASS__, 'isNumber'],
29-
'numeric' => [__CLASS__, 'isNumeric'],
30-
'numericint' => [__CLASS__, 'isNumericInt'],
31-
'string' => 'is_string',
32-
'unicode' => [__CLASS__, 'isUnicode'],
33-
'array' => 'is_array',
34-
'list' => [Arrays::class, 'isList'],
30+
'null' => 'is_null',
3531
'object' => 'is_object',
3632
'resource' => 'is_resource',
3733
'scalar' => 'is_scalar',
34+
'string' => 'is_string',
35+
36+
// pseudo-types
3837
'callable' => [__CLASS__, 'isCallable'],
39-
'null' => 'is_null',
40-
'email' => [__CLASS__, 'isEmail'],
41-
'url' => [__CLASS__, 'isUrl'],
42-
'uri' => [__CLASS__, 'isUri'],
38+
'iterable' => 'is_iterable',
39+
'list' => [Arrays::class, 'isList'],
4340
'none' => [__CLASS__, 'isNone'],
44-
'type' => [__CLASS__, 'isType'],
45-
'identifier' => [__CLASS__, 'isPhpIdentifier'],
46-
'pattern' => null,
41+
'number' => [__CLASS__, 'isNumber'],
42+
'numeric' => [__CLASS__, 'isNumeric'],
43+
'numericint' => [__CLASS__, 'isNumericInt'],
44+
45+
// string patterns
4746
'alnum' => 'ctype_alnum',
4847
'alpha' => 'ctype_alpha',
4948
'digit' => 'ctype_digit',
5049
'lower' => 'ctype_lower',
51-
'upper' => 'ctype_upper',
50+
'pattern' => null,
5251
'space' => 'ctype_space',
52+
'unicode' => [__CLASS__, 'isUnicode'],
53+
'upper' => 'ctype_upper',
5354
'xdigit' => 'ctype_xdigit',
54-
'iterable' => 'is_iterable',
55+
56+
// syntax validation
57+
'email' => [__CLASS__, 'isEmail'],
58+
'identifier' => [__CLASS__, 'isPhpIdentifier'],
59+
'uri' => [__CLASS__, 'isUri'],
60+
'url' => [__CLASS__, 'isUrl'],
61+
62+
// environment validation
63+
'type' => [__CLASS__, 'isType'],
5564
];
5665

5766
protected static $counters = [

0 commit comments

Comments
 (0)