Error codes and messages
This page lists every code that validators and request return, with the default message that validators shows.
The same codes and messages come back in JavaScript and Python.
The message option replaces any default message except the required one.
In a message, {label}, {length}, {limit}, {places}, and {date} are replaced with the option's value.
Option codes
These codes come from the options of validators:
| Code | Default message |
|---|---|
required | This field is required, or {label} is required when you set label |
length | Must be exactly {length} characters |
minLength | Minimum {length} characters required |
maxLength | Maximum {length} characters allowed |
minValue | Minimum value is {limit} |
maxValue | Maximum value is {limit} |
decimalPlaces | Maximum {places} decimal places allowed; Maximum 1 decimal place allowed for one place; Decimal values are not allowed for zero |
regex | Invalid format |
minDate | Date must be on or after {date} |
maxDate | Date must be on or before {date} |
after | Date must be after {date} |
before | Date must be before {date} |
Base rule codes
When a base rule fails, the code is the rule's name:
| Code | Default message |
|---|---|
alphaNumeric | Only letters and numbers allowed |
lettersOnly | Only letters allowed |
numbersOnly | Only digits allowed |
number | Must be a valid number |
email | Invalid email format |
password | Password must be at least 8 characters long and include uppercase, lowercase, number, and special character |
date | Enter a valid date |
Preset codes
When a preset's own check fails, the code is the preset's name:
| Code | Default message |
|---|---|
integer | Must be a whole number |
positiveNumber | Must be greater than zero |
amount | Enter a valid amount (up to 2 decimal places) |
weight | Enter a valid weight (up to 3 decimal places) |
percentage | Must be a percentage between 0 and 100 |
decimalUpTo2 | Only decimal numbers up to 2 digits allowed |
decimalUpTo6 | Only decimal numbers up to 6 digits allowed |
mobile | Enter a valid 10-digit mobile number |
pincode | Enter a valid 6-digit PIN code |
vehicleNumber | Enter a valid vehicle number (e.g. KA01AB1234) |
gstin | Enter a valid GSTIN (e.g. 27ABCDE1234F1Z5) |
pan | Enter a valid PAN (e.g. ABCDE1234F) |
ifsc | Enter a valid IFSC code (e.g. HDFC0001234) |
iec | Enter a valid 10-character IEC code |
pastDate | Date cannot be in the future |
futureDate | Date cannot be in the past |
When you build your own rule and set message, the code still names the check that failed, and the message is yours.
API client codes
When request returns ok: false, the code is one of these:
| Code | When |
|---|---|
The server's code or error.code | The server sent a code |
http_<status>, such as http_404 | The server sent an error status without a code |
failed | The server sent a 2xx status, but its body says that the call failed |
timeout | No response arrived within timeout |
network | The call couldn't reach the server; status is 0 |
For API errors, message is the server's message or error text, or null.