File tree Expand file tree Collapse file tree 2 files changed +27
-9
lines changed Expand file tree Collapse file tree 2 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ Izica\Validation
2525
2626### Notice
2727[ https://docs.phalconphp.com/3.4/en/api/phalcon_validation_validator_numericality ]
28- $arOptions which passed in static functions, for example static numeric($arOptions),
29- used as params for new Numericality($arOptions);
28+ ` $arOptions ` which passed in static functions, for example ` static numeric($arOptions) ` ,
29+ used as params for ` new Numericality($arOptions) ` ;
3030
3131You can use it like this
3232```
@@ -67,25 +67,28 @@ Array
6767(
6868 [0] => Array
6969 (
70- [type] => Email
71- [message] => email is not valid
7270 [field] => email
71+ [type] => email
72+ [message] => email is not valid
7373 )
7474
7575 [1] => Array
7676 (
77- [type] => PresenceOf
78- [message] => num is required
7977 [field] => num
78+ [type] => required
79+ [message] => num is required
8080 )
8181
8282 [2] => Array
8383 (
84- [type] => Numericality
85- [message] => num is not numeric
8684 [field] => num
85+ [type] => numeric
86+ [message] => num is not numeric
8787 )
88+
8889)
8990
91+
92+
9093```
9194
Original file line number Diff line number Diff line change @@ -31,6 +31,20 @@ class Validation {
3131 'regex ' => Regex::class,
3232 ];
3333
34+ public static $ arTypes = [
35+ 'PresenceOf ' => 'required ' ,
36+ 'Numericality ' => 'numeric ' ,
37+ 'Email ' => 'email ' ,
38+ 'UniquenessValidator ' => 'unique ' ,
39+ 'Callback ' => 'callback ' ,
40+ 'StringLength ' => 'length ' ,
41+ 'Between ' => 'between ' ,
42+ 'File ' => 'file ' ,
43+ 'Url ' => 'url ' ,
44+ 'Date ' => 'date ' ,
45+ 'Regex ' => 'regex ' ,
46+ ];
47+
3448 function __construct ($ arOptions ) {
3549 $ this ->arOptions = $ arOptions ;
3650 }
@@ -58,10 +72,11 @@ public function validate($arData) {
5872 foreach ($ obMessages as $ obMessage ) {
5973 $ arMessages [] = [
6074 'field ' => $ obMessage ->getField (),
61- 'type ' => $ obMessage ->getType (),
75+ 'type ' => self :: $ arTypes [ $ obMessage ->getType ()] ,
6276 'message ' => $ obMessage ->getMessage (),
6377 ];
6478 }
79+ return $ arMessages ;
6580 }
6681
6782 public static function required (
You can’t perform that action at this time.
0 commit comments