validate

Validates an Indian PIN code.

Input normalisation applied before validation (in order):

  1. Trim leading/trailing whitespace

  2. Strip all internal whitespace (supports India Post display form XXX XXX and any multi-space variants)

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

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

value

Raw PIN code string.

Samples

check(Pincode.validate("560001") == ValidationResult.Valid)
check(Pincode.validate("000001") is ValidationResult.Invalid)