Skip to main content
Identifiers with a known layout, checked on strings. Those with a check digit, such as an ISBN or an IMEI, fail when the digit does not match, which catches most typos.
Book.kt

Generated ids

uuid

uuid(version) on String Checks that the string is a UUID in its 36-character form, such as 123e4567-e89b-12d3-a456-426614174000, in either case. uuid

ulid

ulid() on String Checks that the string is a ULID: 26 Crockford Base32 characters, in either case. ulid

objectId

objectId() on String Checks that the string is a MongoDB ObjectId: 24 hexadecimal digits. objectId

Versions

semver

semver() on String Checks that the string is a Semantic Versioning 2.0 version, such as 1.4.0, 2.0.0-rc.1 or 1.0.0+build.5. A leading v is not accepted. semver

Books, music and products

isbn

isbn() on String Checks that the string is an ISBN-10 or an ISBN-13 with a valid check digit. Spaces and dashes are ignored. isbn

isbn10

isbn10() on String Checks that the string is an ISBN-10 with a valid check digit, which can be X. Spaces and dashes are ignored. isbn10

isbn13

isbn13() on String Checks that the string is an ISBN-13, starting with 978 or 979, with a valid check digit. Spaces and dashes are ignored. isbn13

issn

issn() on String Checks that the string is an ISSN, such as 0317-8471, with a valid check digit, which can be X. The dash is optional. issn

ean

ean() on String Checks that the string is an EAN-8, EAN-13 or GTIN-14 barcode number with a valid check digit. ean

isrc

isrc() on String Checks that the string is an ISRC with no dashes, such as USRC17607839. isrc

Devices and check digits

imei

imei() on String Checks that the string is an IMEI: 15 digits with a valid Luhn check digit. imei

luhn

luhn() on String Checks that the string has only digits, at least two, and its last digit is a valid Luhn check digit. luhn

Hashes

hash

hash(algorithm) on String Checks that the string is a hexadecimal digest of the length algorithm produces. Only the length and the digits are checked: an MD5 and an MD4 hash look the same. hash hash takes a HashAlgorithm: MD4, MD5, SHA1, SHA256, SHA384, SHA512, RIPEMD128, RIPEMD160, TIGER128, TIGER160, TIGER192, CRC32 or CRC32B. It checks the length of the digest and its hexadecimal digits.