• 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).

    Returns PropertyOrGetterDescriptor

    Example

    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).

    Parameters

    • options: undefined

    Returns PropertyOrGetterDescriptor

    Example

    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).

    Parameters

    Returns void

    Example

    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.