Class-validator: question: is there a way to get the lowest level constraints messages without building an iterator to get there?

Created on 12 Apr 2018  路  6Comments  路  Source: typestack/class-validator

I have ValidateNested and just need the message from the constraint that caused the issue.

Current Code:

function retrieveValidationErrorMessage(err: ValidationError): string {
    if (err.children && err.children.length > 0) {
        return retrieveValidationErrorMessage(err.children[0]);
    } else {
        return Object.keys(err.constraints).map(key => err.constraints[key])[0];
    }
}
question

Most helpful comment

You need to traverse down at the moment, but this part will be reworked in the future.

All 6 comments

You need to traverse down at the moment, but this part will be reworked in the future.

Still waiting for that future to come. Any hints on when will this be ready?

Any news about this?

Features in open-source project are like wizards: They are never late, nor they are early, they arrive precisely when they mean to.

Serious part: There is a lot of refactoring and this is a breaking change. First, those parts will be refactored which didn't break the API, and breaking changes will be grouped together.

Closing this for now, but this is on my radar.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

golozubov picture golozubov  路  5Comments

MistyKuu picture MistyKuu  路  3Comments

st-clair-clarke picture st-clair-clarke  路  3Comments

AndyBarron picture AndyBarron  路  3Comments

twittwer picture twittwer  路  6Comments