validation - Validating fields as unique in cakephp 3.0 -
how validate field unique in cakephp 3.0? there doesn't appear validation function listed in api.
you want use rule validateunique
. example, check email address unique on userstable
:-
public function validationdefault(validator $validator) { $validator->add( 'email', ['unique' => [ 'rule' => 'validateunique', 'provider' => 'table', 'message' => 'not unique'] ] ); return $validator; }
details can found in the api docs.
Comments
Post a Comment