Skip to content

Array parameters are not deserialized/validated properly #123

Closed
@marshall007

Description

@marshall007

Given the following decorated parameters on a controller method:

@QueryParam('fields') fields: string[],
@QueryParam('numbers') numbers: number[]

... the behavior of arrays in query parameters is inconsistent. Namely single values are not coerced to an array and the inner values are not coerced or validated against the appropriate type. Some examples:

// GET ?fields=name
// -> ParameterParseJsonError: Value (\"name\") cannot be parsed to JSON

// GET ?fields=foo&fields=bar
console.log(fields) // -> [ "foo", "bar" ]

// GET ?numbers=1&numbers=2
console.log(numbers) // -> [ "1", "2" ] (works, but not deserialized)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions