1) How are you doing the validation in SaveBookingObject? Depending on the validation scheme you should be able to customize which fields are required in there.
2) The way I list is all violations is to create RuleViolationException that extends Exception and adds and IEnumerable of rule violations like so
public class RuleValidationException : Exception
{
public IEnumerable<RuleViolation> RuleViolations { get; private set; }
public RuleValidationException(string message, IEnumerable<RuleViolation> ruleViolations)
: base(message)
{
RuleViolations = ruleViolations;
}
}In the respoistory I throw a RuleValidationException and put all the violations in there and then catch it and add it to modelstate. (you can do this either in the controller directly or in a service).
try{
bs.SaveBookingObject(bookingobject);
}
catch (RuleValidationException e){
var ruleViolations = e.RuleViolations;
foreach (var violation in ruleViolations){
ModelState.AddError(violation.PropertyName, violation.ErrorMessage);
}
}