Unique field validation in cake php 3.8 Model


The main validation in CakePHP is done in models and you can modify as per required.

use Cake\ORM\RulesChecker;
public function validationDefault(Validator $validator)
	return $validator;

public function buildRules(RulesChecker $rules)
   $rules->add($rules->isUnique(['login_id'],'User already exist.'));
   return $rules;  

Leave a Reply

Your email address will not be published. Required fields are marked *

Next Post

Sony LIV premium account

Try share this login details and enjoy. Do […]