Closed wbazant closed 4 years ago
1 I think the default formats are fine and switching to them is simpler, but Yancy could keep the old message formats.
2) There's some potential in using JSON::Validator::Error::TOJSON when replying to the editor after updating a record, instead of `message => "$"e.g. in the Statocles editor the message looks like {"errors":[{"message":"\/path: Missing property."}]} . If there were separate
pathand
message` components, the UI could do something with it.
Now that you mention it, the UI already does: https://github.com/preaction/Yancy/blob/master/lib/Mojolicious/Plugin/Yancy/resources/public/yancy/app.js#L655-L663 -- The path
is used to highlight which fields are having problems. So, we at least need to provide the path
key in the error structure. I think using the default JSON::Validator messages is probably better though, for general consistency.
Well caught, I broke that functionality.
The force-pushed commit above restores a {message, path}
response format that we got for free before. I am guessing that $message ($path)
is formatted somewhere in the UI code, but I don't know where.
I think it's good now!
Awesome, thanks!
Switch to a format
$path: $message
instead of$message ($path)
coming from JSON::Validator::Error::to_string as available in 3.15 in minor places where it's convenient.Do not rely on JSON::Validator::Error being a hash with message and path, because it isn't after 3.15 - instead call methods message and path.