Saturday, January 3, 2015

Validation error on date field , CakePHP 3


/**
 * Actions Model
 */
class ActionsTable extends Table {

public function validationDefault(Validator $validator) {
$validator->add('close_date', 'valid', ['rule' => 'date']);
}
......................

data passed on save for close_date field :
[ 'year' => '2015', 'month' => '01','day' => '02']


error :

Warning (2): preg_match() expects parameter 2 to be string, array given [CORE/src/Validation/Validation.php, line 763]
 protected static function _check($check, $regex) {
 if (is_string($regex) && preg_match($regex, $check)) {
...................................
parameter values ...

$regex = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))([- /.])(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})([- /.])(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$%'

$check = [ 'year' => '2015', 'month' => '01', 'day' => '02' ] -> expecting String for $check parameter ?????

Working two days ago, but after todays update this error apeared ..
is this a recent bug or something is missing ?


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: