inconsistent :key in nested errors
MathieuDerelle opened this issue · comments
Mathieu Derelle commented
I'm using validation outcome in the return payload of my API
(i.e something like render json: outcome.errors
)
I would expect that adding custom errors in nested object would be consistent with the native filtering.
Expected :
{ user : { current_password : { key; 'current_password' } } }
hash :user do
string :current_password, min_length: 6
end
"user": {
"current_password": {
"key": "current_password",
"symbol": "min_length",
"message": "Current Password is too short",
"index": null
}
}
Got :
{ user : { current_password : { key; 'user.current_password' } } }
add_error('user.current_password', :min_length)
"user": {
"current_password": {
"key": "user.current_password",
"symbol": "min_length",
"message": "Current Password is too short",
"index": null
}
}
is it by design ? or is it a bug ?
Eugene Kenny commented
This is a bug, I've opened #149 to fix it.