uploadpack
uploadpack copied to clipboard
Validation rules for min width and height for an image only required when creating a model
I want an image to only be required when a user is creating a model. I also want the image to have a certain minimum width and height. If a user updates a model, they will not need to select an image again, but if they do, the same validation rule for minimum width and height is applied.
I am encountering an issue when updating a model and I dont set an image. The minimum width and height validation rules is always triggered, even though the image is not required. Am I setting the validation rules correctly? What validation rules should I use?
The validation rules I am using are as follows:
'image' => array(
'required' => 'create',
'minWidth' => array(
'rule' => array('minWidth', '680'),
'message' => 'Photo must be at least 680 pixels wide'
),
'minHeight' => array(
'rule' => array('minHeight', '460'),
'message' => 'Photo must be at least 460 pixels tall'
)
),