convector
convector copied to clipboard
Better support for arrays for @Param() decorator
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.
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.