Validate Objects with All

Use the All method to validate an object.

How to refactor object validation with All

When we need to validate an object against a set of rules, we write some if statements to check if the input object breaks at least one of the rules.

For example, let’s check if we can watch a movie with kids. We have decided to watch films with G or PG certificates and all genres but war.

Get hands-on with 1400+ tech skills courses.