validate

Validates an Indian Financial System Code (IFSC).

Input normalisation applied before validation (in order):

  1. Trim leading/trailing whitespace

  2. Strip all internal whitespace (covers copy-paste with spaces)

  3. Uppercase all characters

After normalisation, checks are applied in order — first failing check wins:

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

value

Raw IFSC string in any common input form.

Samples

check(IFSC.validate("HDFC0000001") == ValidationResult.Valid)
check(IFSC.validate("HDFC1000001") is ValidationResult.Invalid)