MichalLytek / class-transformer-validator

A simple plugin for class-transformer and class-validator which combines them in a nice and programmer-friendly API.
MIT License
200 stars 20 forks source link

Synchronous validation #4

Closed nicolaslt closed 7 years ago

nicolaslt commented 7 years ago

Would it be possible to add wrapping of synchronous validation ?

MichalLytek commented 7 years ago

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?

nicolaslt commented 7 years ago

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

MichalLytek commented 7 years ago

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.

nicolaslt commented 7 years ago

Just noticed you implemented it already. :+1: Any indicative release date?

MichalLytek commented 7 years ago

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.

nicolaslt commented 7 years ago

:+1:

MichalLytek commented 7 years ago

Released in v0.4.0! 🎉