class User extends Model {
@ValidateModel
onValidate() {
if (this.name !== VALID_NAME) {
throw new Error(ERROR_MESSAGE);
}
}
@ValidateModel
static onValidate(instance) {
if (instance.name !== VALID_NAME) {
throw new Error(ERROR_MESSAGE);
}
}
}
See also ValidateAttribute.
Used to register a model method that will be called when an instance is being validated. Available as both an instance and static method (static method receives the model as a parameter).
class User extends Model {
@ValidateModel
onValidate() {
if (this.name !== VALID_NAME) {
throw new Error(ERROR_MESSAGE);
}
}
@ValidateModel
static onValidate(instance) {
if (instance.name !== VALID_NAME) {
throw new Error(ERROR_MESSAGE);
}
}
}
See also ValidateAttribute.
Used to register a model method that will be called when an instance is being validated. Available as both an instance and static method (static method receives the model as a parameter).
Optional
propertyDescriptor: PropertyDescriptorclass User extends Model {
@ValidateModel
onValidate() {
if (this.name !== VALID_NAME) {
throw new Error(ERROR_MESSAGE);
}
}
@ValidateModel
static onValidate(instance) {
if (instance.name !== VALID_NAME) {
throw new Error(ERROR_MESSAGE);
}
}
}
See also ValidateAttribute.
Used to register a model method that will be called when an instance is being validated. Available as both an instance and static method (static method receives the model as a parameter).