Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Better support for arrays for @Param() decorator #60

Open
friendly-tech opened this issue Mar 5, 2019 · 1 comment
Open

Better support for arrays for @Param() decorator #60

friendly-tech opened this issue Mar 5, 2019 · 1 comment
Labels
core Core packages enhancement New feature or request help wanted Extra attention is needed

Comments

@friendly-tech
Copy link
Contributor

When you have a param into a controller method that is an array you need to specify the array schema manually.

public async saveBulk(
@Param(yup.array().transform(values => values.map(v => new MyModel(v)))) 
bulkItems: Array<MyModel>): Promise<any> { ... }

but it would be nice if the @Param() decorator could detect the array input type and handle it accordingly, this may well apply to the Validate() decorator as well.

@diestrin diestrin added core Core packages enhancement New feature or request help wanted Extra attention is needed labels May 30, 2019
@diestrin
Copy link
Contributor

You can have a better syntax by doing yup.array().of(MyModel.schema()), even tho, we're missing the transform piece in the .schema() method.

I'll keep this open to add that missing piece to the method. Thanks for reporting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Core packages enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants