Skip to content

Conversation

@MichalLytek
Copy link
Contributor

Implements #40.
@pleerock, you can refactor the name to the better name as a commit to this PR and then merge 😉

@MichalLytek MichalLytek changed the title Added rejecting validation. Validate API - promise rejection Oct 16, 2016
@MichalLytek MichalLytek mentioned this pull request Oct 16, 2016
/**
* Performs validation of the given object based on decorators used in given object class.
*/
restrictValidate(object: Object, options?: ValidatorOptions): Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad name, we need to came up with better name, need to start name with validate*, and something like validateOrThrow() or better.

/**
* Performs validation of the given object based on decorators or validation schema.
*/
restrictValidate(objectOrSchemaName: Object|string, objectOrValidationOptions: Object|ValidationOptions, maybeValidatorOptions?: ValidatorOptions): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to do it DRY. I think this should be easy as:

async restrictValidate(....) {
     const validationErorrs = await this.validate(...);
     if (validationErorrs.length > 0)
            return Promise.reject(validationErorrs);

     return validationErorrs;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that simple - when you have overload signatures, you can use only them, not the 3rd function validate(objectOrSchemaName: Object|string, objectOrValidationOptions: Object|ValidationOptions, maybeValidatorOptions?: ValidatorOptions). I will move the implementation to the private core method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah I hate this problem

MichalLytek added a commit to MichalLytek/class-validator that referenced this pull request Oct 16, 2016
@MichalLytek MichalLytek deleted the pr-42 branch October 16, 2016 18:47
christophercr pushed a commit to christophercr/class-validator that referenced this pull request Feb 14, 2017
@github-actions
Copy link

github-actions bot commented Aug 5, 2020

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants