email(), minLength(3), cpf().
Each one is an extension of ValidationNode<V>, so it is offered only where the value has the type it checks: email()
on a String, positive() on a number, past() on a date.
By type of value
Any value
equalTo, oneOf, noneOf, notNullBooleans
isTrue, isFalseStrings
Length, blank, characters,
matchesNumbers
Range, sign, digits, decimal places, unsigned
Collections
Size, content, duplicates
Maps
Size, keys, values
Dates and times
past, future, after, betweenCalendar
minAge, today, withinNext, weekdayDurations
kotlin.time.Duration rangesBy format of text
Internet
email, url, ipv4, cidr, jwtIdentifiers
uuid, isbn, ean, imei, hashEncodings
base64, hexadecimal, jsonFinance
creditCard, iban, bic, currencyCodeLocation
Countries, locales,
postalCode of 72 countriesColors
hexColor, rgbColor, hslColorDate formats
isoDate, isoDateTime, dateFormatCountries
Documents of 14 countries:
cpf, dni, ein…Phone numbers
phone, mobilePhone, in validity-phoneWhat every constraint has in common
A code, which is its name
A code, which is its name
The violation of
minLength has the code minLength, in every language and every version. Programs branch on the
code; people read the message.A default message you can change
A default message you can change
Every constraint takes a
message, which replaces the default for that call: minLength(3, message = "too short"). The default itself is changed once, in the messages. Each section of these pages says
which message to change.A message built from the value
A message built from the value
A constraint that takes an argument has a second form whose message is a function of the value and the argument:
minLength(3, message = { min -> "has $length characters, needs $min" }).Null arguments check nothing
Null arguments check nothing
max(customer.creditLimit), equalTo(password) or postalCode(country) with a null argument skip the check. The
missing value is reported once, by required on its own property, instead of breaking every rule that reads it.Placeholders in the message
Placeholders in the message
Messages fill
{path}, {value} and the arguments of the constraint by name: must have at least {min} characters.Reading a section
Each constraint on these pages has the same parts:messages { } to change its default message, for the whole application or
for one call. See Messages.
Imports
The general constraints are inio.github.soleworks.validity.constraints, the constraints of a country in a package of
their own, such as io.github.soleworks.validity.constraints.brazil, and the phone constraints in
io.github.soleworks.validity.phone.