I developed a lot of applications in Application Express and I do have some kind of freedom to choose error messages where validations are not defined. To add few types of validations which are defined but not what kind of error message lead me to another problem. Now application is going to UAT and external Testing team is testing these applications raised issue about grammer and consistance syntex of validations.
There are few set of validations which are commonly used in my applications like
Number Specific one
- Item specified is Is number
- Format mask fo item is is 99.9 or 9.9 or 99.9 ( like height and weight fields
- Item range must be between x and y value
- Item valuse must be greater than zero
Date Specific one
- Item must be valid date
- Item must be in format dd/mm/yyyy
- Item must less than sysdate or some other date
General Items – Characters
- Value must be specified (Not Null) one
Now, I created some of the validations and later came to know about its inconsistant nature of it.
I can’t visit all the validations, change the error message and test the application as it was time consuming, errore prone, and boring.
So, here is new way. I declared a varibale in defination which will be like
For number
V_NUMBER_ERROR_1 and Items specified must be a number.
V_NUMBER_ERROR_2 and Item specified must be greater than zero.
I declared all the validations error messages in defination. Then exported whole application in .SQL (which is default one for apex). Opened the code in SQL Navigator or SQL Developer (whichever is used in your organisation as PL/SQL IDE will be fine – Most use TOAD). Searched for validation type as ITEM_IS_NUMBER and replaced error message with
&V_NUMBER_ERROR_1. in single quotes.
Done all the changes (Find and intellegent Replace) and imported application with keeping same application id. Done. Now all the validations with similar nature of errors will have same error message.
User or anyone who don’t like error message can change it at central place only once and all the messages will be replaced.
Great feature of apex. It also saves time when I create more validations on other forms as I don’t have to type long error messages and worry about uppercase/ lowercase/ error text and just paste error message variable.