How to check and validate if entered values are only numbers for account number or phone number?
Employee Central - Personal Information
Reproducing the Issue
If we use the regular expression ^[0-9]*$, then when no value is furnished for the field then also the matches() result will become true.
matches() returns true when nothing is entered beacuse of technical limitation in RegEx. The same issue discussed here.
- Retrieved 'PaymentInformationDetailV3.accountNumber'. Value: ''
- Call function 'matches' with parameters [, ^[0-9]*$]. Result: 'true'
To overcome this behavior and address your requirement of checking if the field always contain numeric values, you can add an if condition which checks for null like below:
Alternately, you can follow format mentioned in KBA - 2421885
regular expression, regex to check number, validate account number, validate phone number, regular expression to check spaces , KBA , LOD-SF-EC-RUL , Business Rules & Event Derivation , How To