c# - Fluent Validator missing SetCollectionValidator() method -


i'm new fluent validation , got version 5.3 nu yesterday. i'm trying apply existing validator (phonevalidator) collection property (icollection) of class (employee). fluent validator documentation says use:

rulefor(x => x.orders).setcollectionvalidator(new ordervalidator()); // example usage 

however setcollectionvalidator() method not available on version have. instead there setvalidator() marked [deprecated]. i've seen other posts regarding same situation , have learned setcollectionvalidator() extension method , need sure have fluentvalidation imported. do.

what missing here?

using fluentvalidation; using fluentvalidation.validators;  public class employeevalidator : abstractvalidator<employee> {     public employeevalidator()     {                     // setcollectionvalidator doesn't show in intellisense , won't compile         rulefor(e => e.phonenumbers).setcollectionvalidator(new phonevalidator());      } }  public class phonevalidator : abstractvalidator<phone> {     public phonevalidator()     {         rulefor(e => e.number).length(10).matches("^[0-9]$");                 } } 

i'm late party first hit on google thought it'd others. seems api has changed, need do:

ruleforeach(e => e.phonenumbers).setvalidator(new phonevalidator());

a bit nicer in opinion.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -