You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we automatically apply @Allow to all class fields when interface merging? i.e.:
interface ICar {
x: IWheel
y: string
z: number
}
interface Car extends ICar {} // inherits all ICar fields
class Car implements ICar {
@ValidateNested()
x: Wheel
// Also apply @Allow to y, z without explicitly typing it up
constructor(data: ICar) {
Object.assign(this, data, ...)
validate(this, { whitelist: true, forbidNonWhitelisted: true })
}
}
so that we can then assign & validate from an interface without duplicating code
const dto: ICar = JSON.parse(...)
const car: Car = new Car(dto) // can throw validation errors
I understand this is a use case for class-transformer, but it seems like that project is no longer maintained.
The text was updated successfully, but these errors were encountered:
Can we automatically apply
@Allow
to all class fields when interface merging? i.e.:so that we can then assign & validate from an interface without duplicating code
I understand this is a use case for
class-transformer
, but it seems like that project is no longer maintained.The text was updated successfully, but these errors were encountered: