validate
Validates an Indian PIN code.
Input normalisation applied before validation (in order):
Trim leading/trailing whitespace
Strip all internal whitespace (supports India Post display form
XXX XXXand any multi-space variants)
After normalisation, checks are applied in this order — first failing check wins:
InvalidReason.EMPTY if the result is blank
InvalidReason.WRONG_LENGTH if digit count is not 6
InvalidReason.INVALID_FORMAT if any non-digit character remains
InvalidReason.INVALID_PREFIX if the first digit is
'0'
Note: Hyphens are not stripped. "560-001" normalises to "560-001" (7 chars) and returns InvalidReason.WRONG_LENGTH.
Return
ValidationResult.Valid if the PIN code is a valid 6-digit Indian postal code, ValidationResult.Invalid with an appropriate InvalidReason otherwise.
Parameters
Raw PIN code string.
Samples
check(Pincode.validate("560001") == ValidationResult.Valid)
check(Pincode.validate("000001") is ValidationResult.Invalid)