File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ class Form
3333 'email ' => '{field} must be a valid email ' ,
3434 'nospaces ' => '{field} can \'t contain any spaces ' ,
3535 'max ' => '{field} $field can \'t be more than {params} characters ' ,
36- 'min ' => '{field} $field can \'t be less than {params} characters '
36+ 'min ' => '{field} $field can \'t be less than {params} characters ' ,
37+ 'date ' => '{field} must be a valid date ' ,
3738 ];
3839
3940 /**
@@ -50,6 +51,7 @@ class Form
5051 'nospaces ' => null ,
5152 'max ' => null ,
5253 'min ' => null ,
54+ 'date ' => null ,
5355 ];
5456
5557 public static function addError (string $ field , string $ error )
@@ -170,6 +172,13 @@ protected static function rules()
170172 static ::parseMessage ('min ' , $ field , $ value , $ params );
171173 return false ;
172174 }
175+ },
176+ 'date ' => function ($ field , $ value ) {
177+ if (!strtotime ($ value )) {
178+ static ::$ errorsArray [$ field ] =
179+ static ::parseMessage ('date ' , $ field , $ value );
180+ return false ;
181+ }
173182 }
174183 ];
175184
You can’t perform that action at this time.
0 commit comments