I am attempting to manually validate an array from within the model, but validation is successful regardless of what invalid data I populate in the array.
In my CustomerLocation model I am trying to validate $data:
$this->create();
$this->set($data);
if (!$this->validates()){
//some action if validation fails
}
The $data in this case is a simple array:
Array
(
[location_number] => 125-Knoxville - M
[packing_notes] => Test
[packing_label_message] => packing message
[length] => 4
[width] => 4
[height] => 4
[weight] => 4
[shipping_carrier] => UPS
[shipping_service] => 2nd Day Air
[ship_date] =>
[id] => 768
[row] => 4
)
The $data above contains none of the required fields for the CustomerLocation model, so it should totally fail validation.
The source of this $data is an imported .csv row. When I validate from a baked Cake form for this model, the validation works.
Is my $data array not formatted properly for $this->validates? I would expect it to fail rather than pass if that were the case.
Any advice is certainly appreciated!