Skip to content

Error codes ​

LIVR returns error codes, not messages. Codes are stable across implementations, so you can map them to messages in any language of your interface.

Shape of errors ​

Errors have the same shape as the data. Every invalid field gets its error code, nested objects get nested errors, and lists get a list of errors with null for valid elements:

js
{
    name: 'REQUIRED',
    address: { zip: 'NOT_POSITIVE_INTEGER' },
    tags: [null, 'TOO_LONG']
}

An alias can replace the errors of its rules with a single custom code, see Rules aliasing.

All error codes ​

CodeMeaningReturned by
REQUIREDThe value is missing, null or an empty stringrequired
CANNOT_BE_EMPTYThe value is an empty string, or the list is emptynot_empty, not_empty_list
FORMAT_ERRORThe value has a wrong type: an object or a list where a primitive value is expected, or vice versaAlmost every rule, see below
NOT_ALLOWED_VALUEThe value is not one of the allowed valueseq, one_of
TOO_LONGThe string is too longmax_length, length_between, length_equal
TOO_SHORTThe string is too shortmin_length, length_between, length_equal
WRONG_FORMATThe string does not match the regular expressionlike
NOT_INTEGERThe value is not an integerinteger
NOT_POSITIVE_INTEGERThe value is not an integer greater than zeropositive_integer
NOT_DECIMALThe value is not a numberdecimal
NOT_POSITIVE_DECIMALThe value is not a number greater than zeropositive_decimal
NOT_NUMBERThe value is not a numbermax_number, min_number, number_between
TOO_HIGHThe number is too highmax_number, number_between
TOO_LOWThe number is too lowmin_number, number_between
WRONG_EMAILThe value is not an emailemail
WRONG_URLThe value is not an http or https URLurl
WRONG_DATEThe value is not an ISO 8601 dateiso_date
FIELDS_NOT_EQUALThe value differs from the value of another fieldequal_to_field

FORMAT_ERROR ​

FORMAT_ERROR means that the value has a type the rule cannot handle:

  • string, numeric and special rules return it for objects and lists;
  • any_object and nested_object return it for anything that is not an object;
  • not_empty_list, list_of, list_of_objects and list_of_different_objects return it for anything that is not a list (or a list of objects);
  • variable_object and list_of_different_objects also return it when the selector field is missing or has an unknown value.

Modifiers never return errors. All rules except required, not_empty and not_empty_list skip empty values (missing, null or ""), so for them an empty value never causes FORMAT_ERROR.