Last active
February 27, 2016 08:38
-
-
Save ericelliott/94cb04b9b4b575ff413b to your computer and use it in GitHub Desktop.
Siren Error Extension Proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"class": [ | |
"error", | |
"UnprocessableEntity", | |
"api" | |
], | |
"properties": { | |
"message": "Unprocessable entity. The submission failed resource validation.", | |
"code": 422 | |
}, | |
"entities": [ | |
{ | |
"class": [ | |
"error", | |
"validation", | |
"maxlength" | |
], | |
"properties": { | |
"message": "The maximum length is 64 characters.", | |
"id": "title" | |
} | |
}, | |
{ | |
"class": [ | |
"error", | |
"validation", | |
"pattern" | |
], | |
"properties": { | |
"message": "The list price must be a valid US currency.", | |
"id": "listPrice" | |
} | |
} | |
], | |
"actions": [ | |
{ | |
"name": "retry", | |
"href": "/albums", | |
"method": "POST", | |
"fields": [ | |
{ | |
"type": "text", | |
"name": "title", | |
"maxLength": 64 | |
}, | |
{ | |
"type": "number", | |
"name": "listPrice", | |
"pattern": "[+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\\.[0-9]{2})?" | |
} | |
] | |
} | |
], | |
"links": [ | |
{ | |
"rel": [ | |
"index" | |
], | |
"href": "/albums" | |
} | |
] | |
} |
Gist updated.
A more compact version utilizing the non-standard entityAttributes
:
{
"class": [
"error",
"UnprocessableEntity",
"api"
],
"properties": {
"message": "Unprocessable entity. The submission failed resource validation.",
"code": 422
},
"entityAttributes": {
"class": [
"error",
"validation",
"maxlength"
]
},
"entities": [
{
"properties": {
"message": "The maximum length is 64 characters.",
"id": "title"
}
},
{
"properties": {
"message": "The list price must be a valid US currency.",
"id": "listPrice"
}
}
],
"actions": [
{
"name": "retry",
"href": "/albums",
"method": "POST",
"fields": [
{
"type": "text",
"name": "title",
"maxLength": 64
},
{
"type": "number",
"name": "listPrice",
"pattern": "[+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\\.[0-9]{2})?"
}
]
}
],
"links": [
{
"rel": [
"index"
],
"href": "/albums"
}
]
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Echoing back user inputs can result in exploitable attack vectors. I'd advise people to check the server logs for debugging.