I have added two new callbacks beforeValidation and afterValidation : The latter would only run if all validations was sucessful
$fileUploader->addCallback('beforeValidation', function (FileUpload\File $file
) {
//about to validate the upload;
});
$fileUploader->addCallback('afterValidation', function (FileUpload\File $file
) {
//Yay, we got only valid uploads
});
I also splitted the Simple Validator into two (MimeType and SizeValidator) since sometimes the mimetype might only be what should be validated. And the SizeValidator also accepts a min value, all this were not in the simple validator ;
I also edited the Validator interface a bit since the validate method had a param $tmp_name that wasn't used (was redundant).
I also edited the setMessages method by allowing the default message to be over-riden/changed by the user, array_merge was used initially but it always didn't reflect the new error messages set by the user since it incremented the error array count. That said, a constant is used to define the error message in the validate method meaning the new error messages would never be shown.
I have added two new callbacks
beforeValidation
andafterValidation
: The latter would only run if all validations was sucessfulI also splitted the Simple Validator into two (MimeType and SizeValidator) since sometimes the mimetype might only be what should be validated. And the SizeValidator also accepts a min value, all this were not in the simple validator ;
I also edited the Validator interface a bit since the
validate
method had a param$tmp_name
that wasn't used (was redundant).I also edited the
setMessages
method by allowing the default message to be over-riden/changed by the user,array_merge
was used initially but it always didn't reflect the new error messages set by the user since it incremented the error array count. That said, a constant is used to define the error message in thevalidate
method meaning the new error messages would never be shown.I also wrote Unit Tests for the new validators