CakePHP 3 validation params -


is right in cakephp 3?

$validator  ->add('fieldname', [     'rulename' => [         'rule' => 'isunique',         'required' => true,         'allowempty' => null,         'on' => null,         'last' => false,         'message' => null     ] ]); 

or should in following way

$validator   ->requirepresence('fieldname')   ->notempty('fieldname', 'this field required')   ->add('fieldname', [     'rulename' => [         'rule' => 'isunique',         'on' => null,         'last' => false,         'message' => 'this field required',     ] ]) 

i need know if both forms correct. or right way , why?

try this, generate cake

public function validationdefault(validator $validator) {         $validator             ->integer('id')             ->allowempty('id', 'create');          $validator             ->requirepresence('name', 'create')             ->notempty('name')          return $validator;  } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -