format

fun format(value: String): String(source)

Formats a validated PIN code in India Post canonical display form: XXX XXX.

Input is normalised the same way as validate before formatting. Output always has a single space after the third digit: e.g. "560 001". This method is idempotent: format(format(x)) == format(x).

Return

Formatted display string in XXX XXX form.

Parameters

value

Raw PIN code string.

Throws

if value is not a valid Indian PIN code. The exception message includes the (truncated) input for diagnostics.

Samples

check(Pincode.format("560001") == "560001")