Loading…

What is Validation Model in CakePHP?

CakePHP provide a very simple but powerful validation model so that we can easily manage our data validation. To do validation in CakePHP we can just need to declare a $validate array in your model class for required fields.

Example

                                        


public $validate = array(
'email' => array(
'rule' => 'email',
'message' => 'Can you please enter a valid email address.',
'required' => true
),
'phone' => array(
'rule' => array('minLength', '10'),
'message' => 'Can you please enter a valid mobile number.',
'allowEmpty' => true
)
);

Suggest An Answer

No suggestions avaliable!

Latest post from CakePHP interview questions

Ask Question