validate
Validates an Indian Financial System Code (IFSC).
Input normalisation applied before validation (in order):
Trim leading/trailing whitespace
Strip all internal whitespace (covers copy-paste with spaces)
Uppercase all characters
After normalisation, checks are applied in order — first failing check wins:
InvalidReason.EMPTY if the result is blank
InvalidReason.WRONG_LENGTH if length is not 11
InvalidReason.INVALID_FORMAT if the string does not match
[A-Z]{4}0[A-Z0-9]{6}
The regex encodes all structural constraints simultaneously:
Characters 1–4 must be
[A-Z]Character 5 must be
'0'(RBI reserved position)Characters 6–11 must be
[A-Z0-9]
Note: Hyphens are not stripped. "HDFC-0000001" normalises to a 12-character string and returns InvalidReason.WRONG_LENGTH.
Return
ValidationResult.Valid if the code is a valid RBI IFSC, ValidationResult.Invalid with an appropriate InvalidReason otherwise.
Parameters
Raw IFSC string in any common input form.
Samples
check(IFSC.validate("HDFC0000001") == ValidationResult.Valid)
check(IFSC.validate("HDFC1000001") is ValidationResult.Invalid)