VPA
Validator and formatter for UPI Virtual Payment Addresses (VPA).
A VPA (also called UPI ID) is a public payment handle used in NPCI UPI transactions. Format: username@psp where username is an alphanumeric handle (dots, underscores, dashes allowed) and psp is the PSP/bank handle (e.g. ybl, oksbi, okhdfcbank).
Accepted input forms (all normalised before validation):
Lowercase:
"user@ybl"— canonical NPCI formMixed case:
"User@YBL"— normalised to"user@ybl"Uppercase:
"USER@YBL"— normalised to"user@ybl"Whitespace padded:
" user@ybl "— leading/trailing trimmed
Validation rules (post-normalization):
Maximum 50 characters total (NPCI spec)
Username minimum 3 characters
Exactly one
@separating username and PSPUsername:
[a-z0-9._-]{3,}PSP:
[a-z0-9.-]+
PSP allowlist: Not enforced. NPCI adds PSPs regularly — a closed list would produce false negatives on legitimate handles. Structural validation only.
VPA is a public payment handle — shared openly to receive money. No mask() method is provided. See the KotIndia API design rationale for details.
This object is stateless and thread-safe.
Samples
VPA.validate("user@okaxis") // ValidationResult.Valid
VPA.format("User@OkAxis") // "user@okaxis"