-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] - Documentation on $error in schemas #97
Comments
Unfortunately we don't have docs for $error yet. $error can be a string or an object. {
"type": "number",
"minimum": 18,
"maximum": 65,
"$error": "Number must be in range 18-65"
} If schema is invalid the error will always be "Number must be in range 18-65". If $error is an object, then the keys represent the keyword and the value the error message. {
"type": "number",
"minimum": 18,
"maximum": 65,
"$error": {
"minimum": "Too young",
"maximum": "Too old"
}
} If the {
"type": "number",
"minimum": 18,
"maximum": 65,
"$error": {
"minimum": "Too young",
"*": "Invalid number"
}
} If the These are basic examples on how to use the $error keyword. Also keep in mind that this is something specific to opis/json-schema, it is an attempt at providing user defined error messages embedding them in json-schemas. |
Ok thank you, I have a case with some anyOf and some const for a dropdown select and it yields at me for every line of the anyOf, but I will do some testing with what you just said :) |
Docs were added https://opis.io/json-schema/2.x/errors.html |
Hi, I see that we can specify a $error in a schema, but I can't find any documentation about it and how to use it.
Am I missing something?
The text was updated successfully, but these errors were encountered: