Open
Description
Description
Note: Requested by @slavafomin, this issue is created from #57.
Users should be able to allow defining different groups for plainToClass and classToPlain. Example:
@Exclude()
class User {
@Expose({ toClassOnly: true, groups: ["create", "update"] })
@Expose({ toPlainOnly: true })
public email?: string;
@Expose({ toClassOnly: true, groups: ["create", "update"] })
@Expose({ toPlainOnly: true })
public firstName?: string;
@Expose({ toClassOnly: true, groups: ["create"] })
@Expose({ toPlainOnly: true })
public password?: string;
}
const instance = plainToClass(User, {
email: "email@example.com",
firstName: "John",
password: "12345"
}, { groups: ["update"] });
/* Instance should be { firstName: 'John', email: 'email@example.com' }*/
// parameter is a User instance
const json= classToPlain(<User>{
email: "email@example.com",
firstName: "John",
password: "12345"
});
/* JSON should be { firstName: 'John', password: '12345', email: 'email@example.com' }*/
We need to discuss what is the motivation behind this and can we achieve this with the current toolset or not.