CakePHP multirule validation
I am trying to get multiple rules to run during an upload validation. One validation is built in and one is custom. The custom one works fine however the built in one is not working. The custom one extension
was working on another field earlier just fine. Do I have this setup correct?
var $validate = array(
'description' => array(
'rule' => 'notEmpty',
'message' => 'This field cannot be left blank.',
'required' => true
),
'title' => array(
'rule' => 'notEmpty',
'message' => 'This field cannot be left blank.',
'required' => true
),
'Filedata' => array(
'rule' => array('FileExtCheck'),
'message' => 'Please supply a valid type.',
'required' => true
),
'Thumbdata' => array(
'dimensions'=>array(
'rule' => array('dimensions','120','142'),
'message' => 'Your image dimensions are incorrect: 120x142'
),
'extensio开发者_StackOverflown' => array(
'rule' => array('extension'=>array('jpg','jpeg','png')),
'message' => 'Please supply a valid type.',
'required'=>true
)
)
);
The one I am having issue with is Thumbdata
. I want the Thumbdata field to be required and make sure it has correct dimensions and is an image of jpg, jpeg or png. I don't want animated gif's.
I guess, you have a syntax error - unnecessary =>
. Should be:
'rule' => array('extension', array('jpg','jpeg','png')),
精彩评论