20.1.2.2 Validating By Returning Error Text

Validate input with a function body that returns null for success or error text for failure.

A validation can also use type Function Body (returning Error Text). If it returns null, then the validation is a success. Any other return value is used as the error message text. It can use APEX_LANG.GET_MESSAGE as shown below to return a translatable message with placeholders. The validation named At least one over 100 uses this approach.

The translatable Text Message named AT_LEAST_N_ABOVE_M has two placeholders named mincount and limit:
At least %mincount must be greater than %limit
The validation Function Body references it by name, and provides values for the two placeholders using an APEX_T_VARCHAR2 string list of key/value pairs:
return case
         when     :P3_MULTIPLE_OF_TEN < 100 
              and :P3_ODD_MULTIPLE_OF_FIVE < 100
         then
            apex_lang.get_message('AT_LEAST_N_ABOVE_M',
                                  apex_t_varchar2('mincount','1',
                                                  'limit'   ,'100'))
end;

Tip:

A CASE expression with no ELSE clause returns NULL if no WHEN condition is met.

Figure 20-6 Validation Signals Failure by Returning the Error Text