I am using NesteJs and I am looking for a way to instruct @ValidateNested to skip properties that are not defined in the class without triggering an error:
property should not exists
Here are my classes:
export default class InitialConfigClass extends SharedInitialConfigClass {
@Transform((value) => plainToClass(SettingsClass, value))
@IsNotEmpty()
@ValidateNested()
@Type(() => SettingsClass)
settings!: SettingsClass;
}
export class SettingsClass {
@IsNotEmpty()
@ValidateNested()
@Type(() => FormatSettingsClass)
first_config!: FormatSettingsClass;
@IsNotEmpty()
@ValidateNested()
@Type(() => FormatSettingsClass)
second_config!: FormatSettingsClass;
[key: string]: any;
}
Purpose:
- I want to be able to include additional properties under the settings object without causing ValidateNested to throw an error, and without having to define them in SettingClass