Skema uses err-object to standardize error objects.
There are two kinds of errors
- data errors
- initialization errors
Initialization errors are generated by methods other than .from()
, such as shape()
, type()
, etc. And they have following properties:
- code
string(UPPERCASED_STRING)
error codes. - message
string
The error message. - args
Array<any>
The arguments passed to message template of the error.
Error {
message: "unknown type 'hahaha'",
args: ['hahaha'],
code: 'UNKNOWN_TYPE'
}
Data errors are generated by .from()
method, and have following properties:
- input
any
The input value of the current property - key
string | number | null
the key of the current propertystring
if the parent is an objectnumber
if the parent is an arraynull
if there is no parent
- path The accessing path of keys to reach the current property
- code
- message
- args