Reuse rule set validator

Aug 6, 2012 at 3:06 PM
Edited Aug 6, 2012 at 3:13 PM
is it possible?
[Test]
public void Update()
{
            var cm = bll.Get(id);
            cm.Entity.Addresses = new List
(){new Address(){Description = ""}}; var vali = new AutoCommunicationClaimValidator(); var result = vali.Validate(cm, ruleSet: "Update"); var erros = result.Errors; }



public AutoCommunicationClaimValidator() { RuleSet("Update", () => { RuleFor(x => x.Entity.Addresses).NotNull() .SetCollectionValidator(new AddressValidator("Create")); }); } }
 public class AddressValidator : AbstractValidator
{ public AddressValidator(string rule) { if (rule == "Create") { RuleSet(rule, () => RuleFor(x => x.Description) .NotEmpty().WithMessage("Ronaldo")); } } }

May 17, 2013 at 6:50 PM
Did you figure out if this worked?