It seems like when I turn off “strict mode” on a model (in decorator settings:{strict:false}) for the purpose of allowing custom model properties, I still get a ValidationError as the parent constructor is called. I have to remove this property key from the Partial data object before calling the parent constructor, and then I can add safely add the value after the parent constructor is called, like this:
constructor(data?: Partial<User>) {
let user_role;
if (data && data.user_role) {
user_role = data.user_role;
delete data.user_role;
}
super(data);
if (user_role) {
this.user_role = user_role;
}
}
The error:
The `Users` instance is not valid. Details: `user_role` is not defined in the model (value: undefined).
Is there a clean solution I'm not seeing?