Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Check child objects

$
0
0
Hi

You can use a Must rule to do this - the Must method takes a delegate where you can perform custom logic:
class MyValidator:AbstractValidator<Parent> {
  public MyValidator() {
    RuleFor(x => x.Children).Must(HaveValidChildren);
  }
  private bool HaveValidChildren(Parent parent, Child[] children) {
      // loop over each child and compare to parent as necessary.
  }
}
Hope this helps

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>