cypriss / mutations

Compose your business logic into commands that sanitize and validate input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inconsistent :key in nested errors

MathieuDerelle opened this issue · comments

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 ?

This is a bug, I've opened #149 to fix it.