Hi all,
I am currently using Fluentvalidation to validate some ViewModels on our site.
On an insert, certain properties are required, and on an update, those certain properties are still required, with the addition of the ID property of the model in question.
Appreciate any thoughts on this. Thanks!
I am currently using Fluentvalidation to validate some ViewModels on our site.
On an insert, certain properties are required, and on an update, those certain properties are still required, with the addition of the ID property of the model in question.
RuleSet("InsertRules", () =>
{
RuleFor(x => x.DoctorLastName)
.NotEmpty().WithMessage("Last Name must be supplied.");
});
RuleSet("UpdateRules", () =>
{
RuleFor(x => x.DoctorID)
.NotEmpty().WithMessage("DoctorID must be supplied.")
.GreaterThan(0).WithMessage("Invalid DoctorID.");
});
Is there a way that I could allow my code to specify only the UpdateRules
ruleset, and know that the InsertRules
ruleset would be triggered as well? Thinking this would be cleaner than specifying "*"
in our case , and would make the calling code more explicit as to what it was trying to do.Appreciate any thoughts on this. Thanks!