I need to check the input based on a regular expression.
//Validator $validator ->notEmpty('sl_no') ->add('reg_no', 'validFormat',[ 'rule' => '/^([ABCD]{2,2}[0-9]{4,4})$/i', 'message' => 'Please enter a valid serial number.' ]);
But I get the following error:
The method / ^ ([ABCD] {2,2} [0-9] {4,4}) $ / i does not exist.
In addition, there is no mention of regular expressions in Cake 3.0 validation documentation , unlike Cake 2 documentation.
Was it changed or changed?
try it
$validator ->notEmpty('sl_no') ->add('reg_no', 'validFormat',[ 'rule' => array('custom', '/^([ABCD]{2,2}[0-9]{4,4})$/i'), 'message' => 'Please enter a valid serial number.' ]);