Think she dates examples plsql validating for in the best
How often have you already created an APEX validation to make sure that a money amount is greater or egal to 0.00, a percentage value is between 0 and 100 or that an entered date is less or equal to today?
There is some work involved doing that.
- You have to create a validation to make sure that the entered value is numeric.
- Create another validation which only fires if the previous one returned OK.
- Enter the check as PL/SQL expression or SQL Expression
- Think about a good error message
Hmmm, there has to be an easier and faster way to do that.
There is! 🙂
I added a declarative range check for Page Items/Tabular Form Columns in the recent release of the ApexLib Framework.
You can try it on my Feature demonstration web-site.
It’s now possible to define the min-/max value for a field/column. This boundaries are checked immediately in the browser when you leave the field and for security reasons the same check is also done when you submit your page to the server.
You just have to put the ApexLib hints $APEXLIB_MIN_VALUE=min value$ and/or $APEXLIB_MAX_VALUE=max value$ into the Page Item comment or Link Attributes of Tabular Form Columns as you already do for other ApexLib hints.
You can assign fixed values. Eg. $APEXLIB_MIN_VALUE=0$ $APEXLIB_MAX_VALUE=100$ to do a range check or use $APEXLIB_MIN_VALUE=01-JAN-2007$ to check against a fixed date.
But you can also make it more dynamic and reference other Application Items/Page Items. Eg. $APEXLIB_MAX_VALUE=&F111_TODAY.$ to check that the user doesn’t enter a date which is greater than today.
For Tabular Form Columns you can also use the #COLUMN_NAME# notation to reference a column cell value of the same row. Eg. $APEXLIB_MIN_VALUE=#SALARY#$
If you reference a page item/column on the current page, the min/max value changes when you modify the referenced field.
Note: The values specified, independent if they are fixed or dynamic have to comply to the format mask of the current item/column!!! That means, if your current date picker has DD-MON-YYYY as format mask, the fixed or referenced dynamic value also has to be of that format!
For our above example with the application item F111_TODAY, the corresponding initialization code would be a PL/SQL expression with the following code (we assume the used format mask is DD-MON-YYYY)TO_CHAR(SYSDATE, 'DD-MON-YYYY');
What doesn’t work (yet)?
It’s not possible to enter an expression. For example to reference another field and add 1 day. eg. $APEXLIB_MIN_VALUE=&P4_VALID_FROM.+1$
But I think it’s a good start for now and can save some development work!
BTW, I have also update the “Set” configuration for the ApexLib hints in the case you are using the APEX Builder Plugin. You can find the files in the “BuilderPlugin” directory.