Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get validation rules from FluentValidator

Given a validator extending AbstractValidator and implementing IValidator, I would like to get it's rules. There seems to be no way to do this?

like image 679
Shumii Avatar asked Mar 11 '13 10:03

Shumii


1 Answers

Use the GetEnumerator method from the IValidator interface.

By enumerating through the collection you can inspect the validators applied to each property.

However, it got quite complex when dealing with DelegatingValidators so instead I applied a custom state with a .WithState() onto my validators which I could easily understand.

like image 162
Shumii Avatar answered Sep 20 '22 14:09

Shumii