Error
An object that defines a validation failure.
object
Options
-
message
{string}:A reason why value is in an invalid state.
const error = { "message": "is required" }; -
related
{string|array}:Key names that are related to triggering the invalid state of the current value.
{ "message": "is required", "related": "age"}{ "message": "is required", "related": ["billingZip", "residenceZip"]}If no value is passed, the wild card value (
*) is used internally for grouping.
Wild card
It is common to group errors by the property that triggered the error state. In some cases, it possible to group errors where one error is not identified with a property.
const errors = [
{ message: "is required" },
{
message: "must be a number",
related: "age"
}
];
In this situation, the first object in the array is not identified with a property.
This item will have a related assumed to be *. It possible for this error item
to be grouped with other "orphaned" errors.
const errors = [
{
message: "is required",
related: "*"
}, {
message: "must be a number",
related: "age"
}
];