Implementing alternative error messages in validation rule
Posted: Fri Feb 24, 2012 7:54 pm
I have a validation rule for my file upload field which extends JFormRule and functions correctly when validating.
My next step is to output an error based on which rule has failed; I.e. file type is incorrect, the size is too large or some other error has been encountered. So for example if the type is incorrect I could return the message "Incorrect content type detected" or for size "The file size is too large".
However, while I can return true or false from my overloaded JFormRule::test() method, I cannot set an error message based on the error which has occurred.
Is there some method by which my JFormRule could output a message based on the error encountered rather than having a generalized message such as "There is a problem with the uploaded file; please check the size and type."?
Any help much appreciated.
My next step is to output an error based on which rule has failed; I.e. file type is incorrect, the size is too large or some other error has been encountered. So for example if the type is incorrect I could return the message "Incorrect content type detected" or for size "The file size is too large".
However, while I can return true or false from my overloaded JFormRule::test() method, I cannot set an error message based on the error which has occurred.
Is there some method by which my JFormRule could output a message based on the error encountered rather than having a generalized message such as "There is a problem with the uploaded file; please check the size and type."?
Any help much appreciated.