MichalLytek / class-transformer-validator

A simple plugin for class-transformer and class-validator which combines them in a nice and programmer-friendly API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Synchronous validation

nicolaslt opened this issue · comments

Would it be possible to add wrapping of synchronous validation ?

Of course. I prefer do all the thing async in node.js so I've created only async method. Do you think that I should create new function transformAndValidateSync or just implement it as an option { sync: true } to the already existing transformAndValidate function?

My personal preference would be a new, it makes the return type clearer.

Typescript allows for changing return type of overloaded function, so when { sync: true } option is passed, the returned type is T, not Promise<T>. It is used to return Promise<T[]> when array is passed as parameter.

But as the internals needs to be changes, it's better to create new function than overloading the overloaded method.

Just noticed you implemented it already. 👍
Any indicative release date?

Yes, it's not a breaking change so I will release it today in 0.3.1 😉 0.4.0 has to wait for transform/validate json array.

Released in v0.4.0! 🎉