jwaliszko / ExpressiveAnnotations

Annotation-based conditional validation library.
MIT License
351 stars 123 forks source link

Access parent object properties #156

Closed sstanaland closed 7 years ago

sstanaland commented 7 years ago

First off, I love your library. I've tried several other MVC validation extensions and yours is by far the most flexible and it works.

Reading through the docs, I don't think this is possible, but I wanted to verify.

I have a scenario where I need to validate a child object property as required only if a Boolean property in the top level object is true.

The child object is a List property in the main object.

Any idea how I could handle this scenario?

Thanks Scott

jwaliszko commented 7 years ago

Hi, In this case you need to have a back reference to your parent model: https://github.com/jwaliszko/ExpressiveAnnotations/issues/105. Otherwise there is no way to access it.

Some time ago I've been looking for a way of handling such a requirement but without results.

sstanaland commented 7 years ago

That's what I thought.

Thanks for following up.

Scott