File tree 2 files changed +35
-15
lines changed
2 files changed +35
-15
lines changed Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+ /*
3
+ * This file is part of Aplus Framework Validation Library.
4
+ *
5
+ * (c) Natan Felles <natanfelles@gmail.com>
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ namespace Framework \Validation ;
11
+
12
+ use Framework \Helpers \ArraySimple ;
13
+
14
+ /**
15
+ * Class BaseValidator.
16
+ *
17
+ * @package validation
18
+ */
19
+ abstract class BaseValidator
20
+ {
21
+ /**
22
+ * Get field value from data.
23
+ *
24
+ * @param string $field
25
+ * @param array<string,mixed> $data
26
+ *
27
+ * @return string|null
28
+ */
29
+ protected static function getData (string $ field , array $ data ) : ?string
30
+ {
31
+ $ data = ArraySimple::value ($ field , $ data );
32
+ return \is_scalar ($ data ) ? (string ) $ data : null ;
33
+ }
34
+ }
Original file line number Diff line number Diff line change 18
18
*
19
19
* @package validation
20
20
*/
21
- class Validator
21
+ class Validator extends BaseValidator
22
22
{
23
- /**
24
- * Get field value from data.
25
- *
26
- * @param string $field
27
- * @param array<string,mixed> $data
28
- *
29
- * @return string|null
30
- */
31
- protected static function getData (string $ field , array $ data ) : ?string
32
- {
33
- $ data = ArraySimple::value ($ field , $ data );
34
- return \is_scalar ($ data ) ? (string ) $ data : null ;
35
- }
36
-
37
23
/**
38
24
* Validates alphabetic characters.
39
25
*
You can’t perform that action at this time.
0 commit comments