Skip to content

Allow validation to fail and return after first rule break #339

@sanjarbek

Description

@sanjarbek

Hello guys. I googled but did not find solution for this issue.
Why should I proceed validation of a certain field when the first rule is failed. For instance, I have a validation chain where 2 last validations query the database. Why should I conduct those queries anyway when the first validation is failed, that's waste of resources.
Example:

@isnotempty()
@ISINT()
@Validate(CheckForeignKeyValidator, [ {
targetClass: CategoryEntity.name,
targetAttribute: { referenceField: 'userId', foreignKey: 'id' }
​} ], {
message: "Объект с данным айди не существует"
})
readonly userId: number;

When userId is float number, the third validation runs anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featureIssues related to new features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions