messages { }, in the configuration. Change
any of them once, at startup, or for one call. See Messages for placeholders and the
other ways to change them.
General messages
| Message | Default | Used by |
|---|---|---|
required | is required | notNull, required |
forbidden | must be null | forbidden |
atLeastOneOf | at least one of {fields} is required | atLeastOneOf |
atMostOneOf | at most one of {fields} can be filled | atMostOneOf |
exactlyOneOf | exactly one of {fields} must be filled | exactlyOneOf |
allOrNoneOf | {fields} must be filled together | allOrNoneOf |
atLeastOf | at least {count} of {fields} must be filled | atLeastOf |
atMostOf | at most {count} of {fields} can be filled | atMostOf |
exactlyOf | exactly {count} of {fields} must be filled | exactlyOf |
equalTo | must be equal to {other} | equalTo |
notEqualTo | must not be equal to {other} | notEqualTo |
oneOf | must be one of {values} | oneOf |
enum | must be one of {values} | enum |
noneOf | must not be one of {values} | noneOf |
or | {left} or {right} | or |
and | {left} and {right} | and, or |
not | is not allowed | not |
convert | has an invalid format | convert |
convertToBigDecimal | must be a valid number | convertToBigDecimal |
convertToInt | must be a valid integer | convertToInt |
convertToLong | must be a valid integer | convertToLong |
convertToBigInteger | must be a valid integer | convertToBigInteger |
convertToDouble | must be a valid number | convertToDouble |
convertToBoolean | must be true or false | convertToBoolean |
convertToUuid | must be a valid UUID | convertToUuid |
convertToEnum | must be one of {values} | convertToEnum |
convertToLocalDate | must be a valid ISO 8601 date | convertToLocalDate |
convertToLocalDateTime | must be a valid ISO 8601 date and time | convertToLocalDateTime |
convertToLocalTime | must be a valid ISO 8601 time | convertToLocalTime |
convertToOffsetDateTime | must be a valid ISO 8601 date and time with offset | convertToOffsetDateTime |
convertToInstant | must be a valid ISO 8601 instant | convertToInstant |
convertToYearMonth | must be a valid ISO 8601 year and month | convertToYearMonth |
convertToDuration | must be a valid ISO 8601 duration | convertToDuration |
mustBeTrue | must be true | isTrue |
mustBeFalse | must be false | isFalse |
min | must be at least {min} | min |
max | must be at most {max} | max |
greaterThan | must be greater than {other} | greaterThan |
lessThan | must be less than {other} | lessThan |
between | must be between {min} and {max} | between |
minLength | must have at least {min} characters | minLength |
maxLength | must have at most {max} characters | maxLength |
length | must have exactly {length} characters | length |
lengthBetween | must have between {min} and {max} characters | lengthBetween |
minBytes | must have at least {min} bytes | minBytes |
maxBytes | must have at most {max} bytes | maxBytes |
notEmpty | must not be empty | notEmpty |
empty | must be empty | empty |
notBlank | must not be blank | notBlank |
blank | must be blank | blank |
trimmed | must not start or end with whitespace | trimmed |
matches | must match {regex} | matches |
notMatches | must not match {regex} | notMatches |
contains | must contain {text} | contains |
notContains | must not contain {text} | notContains |
startsWith | must start with {prefix} | startsWith |
notStartsWith | must not start with {prefix} | notStartsWith |
endsWith | must end with {suffix} | endsWith |
notEndsWith | must not end with {suffix} | notEndsWith |
uppercase | must be uppercase | uppercase |
lowercase | must be lowercase | lowercase |
letters | must contain only letters | letters |
digits | must contain only digits | digits |
lettersOrDigits | must contain only letters or digits | lettersOrDigits |
ascii | must contain only ASCII characters | ascii |
containsOnly | must contain only the characters {characters} | containsOnly |
normalized | must be in Unicode {form} form | normalized |
positive | must be positive | positive |
negative | must be negative | negative |
positiveOrZero | must be positive or zero | positiveOrZero |
negativeOrZero | must be negative or zero | negativeOrZero |
multipleOf | must be a multiple of {factor} | multipleOf |
finite | must be finite | finite |
maxDecimalPlaces | must have at most {max} decimal places | maxDecimalPlaces |
maxIntegerDigits | must have at most {max} integer digits | maxIntegerDigits |
decimalPlaces | must have exactly {count} decimal places | decimalPlaces |
minDecimalPlaces | must have at least {min} decimal places | minDecimalPlaces |
minDigits | must have at least {min} digits | minDigits |
maxDigits | must have at most {max} digits | maxDigits |
digitCount | must have exactly {count} digits | digitCount |
past | must be in the past | past |
future | must be in the future | future |
pastOrPresent | must be in the past or present | pastOrPresent |
futureOrPresent | must be in the future or present | futureOrPresent |
after | must be after {other} | after |
before | must be before {other} | before |
afterOrEqual | must be after or equal to {other} | afterOrEqual |
beforeOrEqual | must be before or equal to {other} | beforeOrEqual |
betweenDates | must be between {start} and {end} | between |
minAge | must be at least {min} years old | minAge |
maxAge | must be at most {max} years old | maxAge |
withinNext | must be within the next {duration} | withinNext |
withinLast | must be within the last {duration} | withinLast |
today | must be today | today |
weekday | must be a weekday | weekday |
weekend | must be on a weekend | weekend |
minSize | must have at least {min} items | minSize |
maxSize | must have at most {max} items | maxSize |
size | must have exactly {size} items | size |
sizeBetween | must have between {min} and {max} items | sizeBetween |
distinct | must not contain duplicates | distinct, distinctBy |
containsElement | must contain {element} | contains |
notContainsElement | must not contain {element} | notContains |
containsAll | must contain all of {elements} | containsAll |
containsAny | must contain any of {elements} | containsAny |
containsNone | must not contain any of {elements} | containsNone |
minEntries | must have at least {min} entries | minSize |
maxEntries | must have at most {max} entries | maxSize |
entries | must have exactly {size} entries | size |
entriesBetween | must have between {min} and {max} entries | sizeBetween |
containsKey | must contain the key {key} | containsKey |
containsKeys | must contain the keys {keys} | containsKeys |
notContainsKey | must not contain the key {key} | notContainsKey |
onlyKeys | must contain only the keys {keys} | onlyKeys |
containsValue | must contain the value {other} | containsValue |
email | must be a valid email | email |
url | must be a valid URL | url |
hostname | must be a valid hostname | hostname |
domain | must be a valid domain name | domain |
port | must be a valid port number | port |
ipv4 | must be a valid IPv4 address | ipv4 |
ipv6 | must be a valid IPv6 address | ipv6 |
ip | must be a valid IP address | ip |
cidr | must be a valid CIDR block | cidr |
macAddress | must be a valid MAC address | macAddress |
slug | must be a valid slug | slug |
jwt | must be a valid JWT | jwt |
dataUri | must be a valid data URI | dataUri |
mimeType | must be a valid MIME type | mimeType |
uuid | must be a valid UUID | uuid |
ulid | must be a valid ULID | ulid |
objectId | must be a valid ObjectId | objectId |
semver | must be a valid semantic version | semver |
isbn | must be a valid ISBN | isbn |
isbn10 | must be a valid ISBN-10 | isbn10 |
isbn13 | must be a valid ISBN-13 | isbn13 |
issn | must be a valid ISSN | issn |
ean | must be a valid EAN | ean |
isrc | must be a valid ISRC | isrc |
imei | must be a valid IMEI | imei |
luhn | must have a valid Luhn check digit | luhn |
hash | must be a valid {algorithm} hash | hash |
base64 | must be valid Base64 | base64 |
base64Url | must be valid URL-safe Base64 | base64Url |
base32 | must be valid Base32 | base32 |
base58 | must be valid Base58 | base58 |
hexadecimal | must be hexadecimal | hexadecimal |
json | must be valid JSON | json |
hexColor | must be a valid hexadecimal color | hexColor |
rgbColor | must be a valid RGB color | rgbColor |
hslColor | must be a valid HSL color | hslColor |
creditCard | must be a valid credit card number | creditCard |
iban | must be a valid IBAN | iban |
bic | must be a valid BIC | bic |
isin | must be a valid ISIN | isin |
currencyCode | must be a valid ISO 4217 currency code | currencyCode |
bitcoinAddress | must be a valid Bitcoin address | bitcoinAddress |
ethereumAddress | must be a valid Ethereum address | ethereumAddress |
isoCountryCode | must be a valid ISO 3166-1 alpha-2 country code | isoCountryCode |
isoCountryCodeAlpha3 | must be a valid ISO 3166-1 alpha-3 country code | isoCountryCodeAlpha3 |
languageCode | must be a valid ISO 639-1 language code | languageCode |
locale | must be a valid locale | locale |
timeZone | must be a valid time zone | timeZone |
latitude | must be a valid latitude | latitude |
longitude | must be a valid longitude | longitude |
coordinates | must be a valid latitude and longitude pair | coordinates |
postalCode | must be a valid postal code for {country} | postalCode |
numeric | must be numeric | numeric |
integer | must be an integer | integer |
boolean | must be true or false | boolean |
containsUppercase | must contain an uppercase letter | containsUppercase |
containsLowercase | must contain a lowercase letter | containsLowercase |
containsDigit | must contain a digit | containsDigit |
containsSymbol | must contain a symbol | containsSymbol |
isoDate | must be an ISO 8601 date | isoDate |
isoTime | must be an ISO 8601 time | isoTime |
isoDateTime | must be an ISO 8601 date and time with offset | isoDateTime |
isoDuration | must be an ISO 8601 duration | isoDuration |
dateFormat | must match the date format {pattern} | dateFormat |
Countries
Each country has a block:messages { brazil { cpf = "…" } }.
| Block | Message | Default | Used by |
|---|---|---|---|
brazil | cpf | must be a valid CPF | cpf |
brazil | cnpj | must be a valid CNPJ | cnpj |
brazil | cnh | must be a valid CNH | cnh |
brazil | pis | must be a valid PIS | pis |
brazil | cep | must be a valid CEP | cep |
brazil | placa | must be a valid license plate | placa |
bulgaria | egn | must be a valid EGN | egn |
canada | sin | must be a valid SIN | sin |
france | spi | must be a valid SPI | spi |
israel | teudatZehut | must be a valid teudat zehut | teudatZehut |
netherlands | bsn | must be a valid BSN | bsn |
pakistan | cnic | must be a valid CNIC | cnic |
poland | pesel | must be a valid PESEL | pesel |
poland | nip | must be a valid NIP | nip |
russia | innIndividual | must be a valid individual INN | innIndividual |
russia | innLegalEntity | must be a valid legal entity INN | innLegalEntity |
slovenia | davcnaStevilka | must be a valid davčna številka | davcnaStevilka |
spain | dni | must be a valid DNI | dni |
spain | nie | must be a valid NIE | nie |
thailand | nationalId | must be a valid national identification number | nationalId |
ukraine | rnokpp | must be a valid RNOKPP | rnokpp |
unitedStates | ein | must be a valid EIN | ein |
Phone numbers
Invalidity-phone, with the block messages { phone { … } }.
| Message | Default | Used by |
|---|---|---|
phone | must be a valid phone number | phone |
mobilePhone | must be a valid mobile phone number | mobilePhone |
countryCode | must be a valid country calling code | countryCode |
areaCode | must be a valid area code | areaCode |
A template to translate
Every message with its default, ready to copy and translate. Keep the placeholders in braces: they are filled in when a violation is built. Thephone { } block needs validity-phone and the import
io.github.soleworks.validity.phone.phone; remove it when you do not use the module.
Ask your agent: “Translate this Validity messages template to Spanish, keeping the placeholders.” It can read
this page as Markdown at
/reference/messages.md.Every message
Validity.configure {
messages {
required = "is required"
forbidden = "must be null"
atLeastOneOf = "at least one of {fields} is required"
atMostOneOf = "at most one of {fields} can be filled"
exactlyOneOf = "exactly one of {fields} must be filled"
allOrNoneOf = "{fields} must be filled together"
atLeastOf = "at least {count} of {fields} must be filled"
atMostOf = "at most {count} of {fields} can be filled"
exactlyOf = "exactly {count} of {fields} must be filled"
equalTo = "must be equal to {other}"
notEqualTo = "must not be equal to {other}"
oneOf = "must be one of {values}"
enum = "must be one of {values}"
noneOf = "must not be one of {values}"
or = "{left} or {right}"
and = "{left} and {right}"
not = "is not allowed"
convert = "has an invalid format"
convertToBigDecimal = "must be a valid number"
convertToInt = "must be a valid integer"
convertToLong = "must be a valid integer"
convertToBigInteger = "must be a valid integer"
convertToDouble = "must be a valid number"
convertToBoolean = "must be true or false"
convertToUuid = "must be a valid UUID"
convertToEnum = "must be one of {values}"
convertToLocalDate = "must be a valid ISO 8601 date"
convertToLocalDateTime = "must be a valid ISO 8601 date and time"
convertToLocalTime = "must be a valid ISO 8601 time"
convertToOffsetDateTime = "must be a valid ISO 8601 date and time with offset"
convertToInstant = "must be a valid ISO 8601 instant"
convertToYearMonth = "must be a valid ISO 8601 year and month"
convertToDuration = "must be a valid ISO 8601 duration"
mustBeTrue = "must be true"
mustBeFalse = "must be false"
min = "must be at least {min}"
max = "must be at most {max}"
greaterThan = "must be greater than {other}"
lessThan = "must be less than {other}"
between = "must be between {min} and {max}"
minLength = "must have at least {min} characters"
maxLength = "must have at most {max} characters"
length = "must have exactly {length} characters"
lengthBetween = "must have between {min} and {max} characters"
minBytes = "must have at least {min} bytes"
maxBytes = "must have at most {max} bytes"
notEmpty = "must not be empty"
empty = "must be empty"
notBlank = "must not be blank"
blank = "must be blank"
trimmed = "must not start or end with whitespace"
matches = "must match {regex}"
notMatches = "must not match {regex}"
contains = "must contain {text}"
notContains = "must not contain {text}"
startsWith = "must start with {prefix}"
notStartsWith = "must not start with {prefix}"
endsWith = "must end with {suffix}"
notEndsWith = "must not end with {suffix}"
uppercase = "must be uppercase"
lowercase = "must be lowercase"
letters = "must contain only letters"
digits = "must contain only digits"
lettersOrDigits = "must contain only letters or digits"
ascii = "must contain only ASCII characters"
containsOnly = "must contain only the characters {characters}"
normalized = "must be in Unicode {form} form"
positive = "must be positive"
negative = "must be negative"
positiveOrZero = "must be positive or zero"
negativeOrZero = "must be negative or zero"
multipleOf = "must be a multiple of {factor}"
finite = "must be finite"
maxDecimalPlaces = "must have at most {max} decimal places"
maxIntegerDigits = "must have at most {max} integer digits"
decimalPlaces = "must have exactly {count} decimal places"
minDecimalPlaces = "must have at least {min} decimal places"
minDigits = "must have at least {min} digits"
maxDigits = "must have at most {max} digits"
digitCount = "must have exactly {count} digits"
past = "must be in the past"
future = "must be in the future"
pastOrPresent = "must be in the past or present"
futureOrPresent = "must be in the future or present"
after = "must be after {other}"
before = "must be before {other}"
afterOrEqual = "must be after or equal to {other}"
beforeOrEqual = "must be before or equal to {other}"
betweenDates = "must be between {start} and {end}"
minAge = "must be at least {min} years old"
maxAge = "must be at most {max} years old"
withinNext = "must be within the next {duration}"
withinLast = "must be within the last {duration}"
today = "must be today"
weekday = "must be a weekday"
weekend = "must be on a weekend"
minSize = "must have at least {min} items"
maxSize = "must have at most {max} items"
size = "must have exactly {size} items"
sizeBetween = "must have between {min} and {max} items"
distinct = "must not contain duplicates"
containsElement = "must contain {element}"
notContainsElement = "must not contain {element}"
containsAll = "must contain all of {elements}"
containsAny = "must contain any of {elements}"
containsNone = "must not contain any of {elements}"
minEntries = "must have at least {min} entries"
maxEntries = "must have at most {max} entries"
entries = "must have exactly {size} entries"
entriesBetween = "must have between {min} and {max} entries"
containsKey = "must contain the key {key}"
containsKeys = "must contain the keys {keys}"
notContainsKey = "must not contain the key {key}"
onlyKeys = "must contain only the keys {keys}"
containsValue = "must contain the value {other}"
email = "must be a valid email"
url = "must be a valid URL"
hostname = "must be a valid hostname"
domain = "must be a valid domain name"
port = "must be a valid port number"
ipv4 = "must be a valid IPv4 address"
ipv6 = "must be a valid IPv6 address"
ip = "must be a valid IP address"
cidr = "must be a valid CIDR block"
macAddress = "must be a valid MAC address"
slug = "must be a valid slug"
jwt = "must be a valid JWT"
dataUri = "must be a valid data URI"
mimeType = "must be a valid MIME type"
uuid = "must be a valid UUID"
ulid = "must be a valid ULID"
objectId = "must be a valid ObjectId"
semver = "must be a valid semantic version"
isbn = "must be a valid ISBN"
isbn10 = "must be a valid ISBN-10"
isbn13 = "must be a valid ISBN-13"
issn = "must be a valid ISSN"
ean = "must be a valid EAN"
isrc = "must be a valid ISRC"
imei = "must be a valid IMEI"
luhn = "must have a valid Luhn check digit"
hash = "must be a valid {algorithm} hash"
base64 = "must be valid Base64"
base64Url = "must be valid URL-safe Base64"
base32 = "must be valid Base32"
base58 = "must be valid Base58"
hexadecimal = "must be hexadecimal"
json = "must be valid JSON"
hexColor = "must be a valid hexadecimal color"
rgbColor = "must be a valid RGB color"
hslColor = "must be a valid HSL color"
creditCard = "must be a valid credit card number"
iban = "must be a valid IBAN"
bic = "must be a valid BIC"
isin = "must be a valid ISIN"
currencyCode = "must be a valid ISO 4217 currency code"
bitcoinAddress = "must be a valid Bitcoin address"
ethereumAddress = "must be a valid Ethereum address"
isoCountryCode = "must be a valid ISO 3166-1 alpha-2 country code"
isoCountryCodeAlpha3 = "must be a valid ISO 3166-1 alpha-3 country code"
languageCode = "must be a valid ISO 639-1 language code"
locale = "must be a valid locale"
timeZone = "must be a valid time zone"
latitude = "must be a valid latitude"
longitude = "must be a valid longitude"
coordinates = "must be a valid latitude and longitude pair"
postalCode = "must be a valid postal code for {country}"
numeric = "must be numeric"
integer = "must be an integer"
boolean = "must be true or false"
containsUppercase = "must contain an uppercase letter"
containsLowercase = "must contain a lowercase letter"
containsDigit = "must contain a digit"
containsSymbol = "must contain a symbol"
isoDate = "must be an ISO 8601 date"
isoTime = "must be an ISO 8601 time"
isoDateTime = "must be an ISO 8601 date and time with offset"
isoDuration = "must be an ISO 8601 duration"
dateFormat = "must match the date format {pattern}"
brazil {
cpf = "must be a valid CPF"
cnpj = "must be a valid CNPJ"
cnh = "must be a valid CNH"
pis = "must be a valid PIS"
cep = "must be a valid CEP"
placa = "must be a valid license plate"
}
bulgaria {
egn = "must be a valid EGN"
}
canada {
sin = "must be a valid SIN"
}
france {
spi = "must be a valid SPI"
}
israel {
teudatZehut = "must be a valid teudat zehut"
}
netherlands {
bsn = "must be a valid BSN"
}
pakistan {
cnic = "must be a valid CNIC"
}
poland {
pesel = "must be a valid PESEL"
nip = "must be a valid NIP"
}
russia {
innIndividual = "must be a valid individual INN"
innLegalEntity = "must be a valid legal entity INN"
}
slovenia {
davcnaStevilka = "must be a valid davčna številka"
}
spain {
dni = "must be a valid DNI"
nie = "must be a valid NIE"
}
thailand {
nationalId = "must be a valid national identification number"
}
ukraine {
rnokpp = "must be a valid RNOKPP"
}
unitedStates {
ein = "must be a valid EIN"
}
phone {
phone = "must be a valid phone number"
mobilePhone = "must be a valid mobile phone number"
countryCode = "must be a valid country calling code"
areaCode = "must be a valid area code"
}
}
}