I would like to create the custom validation function in cakephp 3.x
In CakePHP I've frontend and backend panels. Frontend have more fields comparing the backend panel. public function validationDefault(Validator $validator)
. This validation function is call after the action call.
But I want to call a different validation function which will be specify in the controller and check the validation for other fields that are on frontend.
For Example, I have a field name 'company', but it is not in backend. I want to add require validation rule on server site for frontend.
Following function is created on the model:
public function companyValidation(Validator $validator) {
$validator
->requirePresence('company', 'create')
->notEmpty('company');
return $validator;
}
How can I call to companyValidation()
function in the controller?