@@ -7,6 +7,7 @@ A collection of common libraries for PHP 7
7
7
8
8
##### Methods
9
9
10
+ * ` __construct(array $data) ` Create Collection
10
11
* ` set($key, $value) ` Add an item
11
12
* ` get($key, $default = null) ` Get value of item; Returns $default if item doesn't exist
12
13
* ` has($key) : bool ` Check if item exists
@@ -18,4 +19,27 @@ A collection of common libraries for PHP 7
18
19
* ` keys() : array ` Get item keys
19
20
* ` values() : array ` Get item values
20
21
* ` all() : array ` Alias for ` toArray() `
21
- * ` toArray() : array ` Returns collection as an array
22
+ * ` toArray() : array ` Returns collection as an array
23
+
24
+ #### \Noname\Common\Validator
25
+
26
+ <?php
27
+ use \Noname\Common\Validator;
28
+ $values = ['email' => '[email protected] '];
29
+ $rules = ['email' => 'email'];
30
+ $validator = new Validator($values, $rules);
31
+ $valid = $validator->validate();
32
+ if(!$valid){
33
+ print_r($validator->getErrors());
34
+ }
35
+
36
+ ##### Methods
37
+
38
+ * ` __construct(array $data, array $rules, array $settings = []) ` Create Validator
39
+ * $data : array
40
+ * $rules : array
41
+ * $settings : array
42
+ * ` validate() : bool ` Validate data based on supplied rules
43
+ * ` hasErrors() : bool ` Check if validator has errors
44
+ * ` getErrors() : array ` Return validation errors
45
+ * ` validateType($type, $value, array $rule = []) : bool ` Type-specific validator
0 commit comments