What is wrong with the below validation rule?

Answer

'email' => array(
    'rule' => array(
        'rule' => 'notEmpty',
        'message' => 'Please Enter Email address.'
    ),
    'rule' => array(
        'rule' => 'email',
        'message' => 'Entered Email address is invalid.'
    )
)
 
The problem is the first rule notEmpty will never be called because email rule will overwrite it.While using multiple validation rules for the same field you must keep the rule key "unique". In this case if we want to use multiple rules then, we can simple change the rule key names like,
 
 
'email' => array(
    'rule1' => array(
        'rule' => 'notEmpty',
        'message' => 'Please Enter Email address.'
    ),
    'rule2' => array(
        'rule' => 'email',
        'message' => 'Entered Email address is invalid.'
    )
)
 

All cakephp Questions

Ask your interview questions on cakephp

Write Your comment or Questions if you want the answers on cakephp from cakephp Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---