format

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

Formats a valid GSTIN to its canonical form.

Output: 15-character uppercase string with no separator. Example: "27aapfu0939f1zv""27AAPFU0939F1ZV".

Applies the same normalisation as validate (trim + strip whitespace + uppercase) before formatting. Throws IllegalArgumentException if the input is not a valid GSTIN.

This method is idempotent: format(format(x)) == format(x) for any valid input.

Return

Canonical 15-character uppercase GSTIN string with no separator.

Parameters

value

Raw GSTIN string in any common input form.

Throws

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

Samples

check(GSTIN.format("27aapfu0939f1zv") == "27AAPFU0939F1ZV")