Skip to content

Context around array validation failures #1131

Closed
@lukestephenson

Description

@lukestephenson

Given a request like:

{ "orders": [ {customerId: 'invalid', salesPersonId: 5}, {customerId: 5, salesPersonId: 'invalid'} ] }

And the following parameter definitions:

    params do
      requires :orders, type: Array do
        requires :customerId, type: Integer
        requires :salesPersonId, type: Integer
      end
    end

Grape correctly detects that the input is invalid. However there is no context in the errors collection about which item in the array was invalid. Currently the error is reported against the key orders[customerId] but I need to be able to pair the errors back to the original element in the array like orders[0][customerId].

Is this supported by grape?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions