validate
Validates a UPI Virtual Payment Address (VPA).
Input normalisation applied before validation (in order):
Trim leading/trailing whitespace
Lowercase all characters (NPCI canonical form)
Note: Internal whitespace is NOT stripped — VPAs never contain internal spaces, and a space inside a VPA is a format violation.
After normalisation, checks are applied in order — first failing check wins:
InvalidReason.EMPTY if the result is blank
InvalidReason.WRONG_LENGTH if total length exceeds 50
InvalidReason.INVALID_FORMAT if the string does not match
username@psppattern
PSP allowlist not enforced. "user@anypsp" is structurally valid. NPCI adds PSPs regularly; a closed list would produce false negatives.
Return
ValidationResult.Valid if the VPA is structurally valid, ValidationResult.Invalid with an appropriate InvalidReason otherwise.
Parameters
Raw VPA string in any common input form.
Samples
check(VPA.validate("user@okaxis") == ValidationResult.Valid)