typestack / class-validator

Decorator-based property validation for classes.
MIT License
11.03k stars 800 forks source link

Validating specific properties #336

Open adamalfredsson opened 5 years ago

adamalfredsson commented 5 years ago

I would like to reopen this issue:

https://github.com/typestack/class-validator/issues/46

It's a feature I would like. Would a PR be accepted?

validate(user, {
    validateProperties: [
        'name',
        'email',
    ],
});
vlapo commented 5 years ago

Currently you can use validation groups - check https://github.com/typestack/class-validator#validation-groups.

LendaVadym commented 5 years ago

Validation groups is predefined lists of properties, but I think author meant that he f.e. wants to validation only newly changed properties, which set of properties should be validated decided at runtime. I would also vote for this feature.

SpeedOfSpin commented 4 years ago

I would like this too. I just want to be able to validate individual fields so that I can present a message on blur for instance rather than on form submit. thanks.

aabuelenin commented 4 years ago

I believe it's an important feature.

Consider having a deeply nested hierarchy, you'd not want to validate the entire business domain each time a string value changes (i.e. a user presses a key), but rather validate that particular property.