public void Validate(RulesBaseParams parameters) { ValidateModelPropertiesAndBuildRulesException(this); if (string.IsNullOrEmpty(Foo)) { RulesException.ErrorFor(x => x.Foo, "Please supply a Foo"); } if (parameters.ThrowException) { RulesException.ThrowException(); } }
public void Validate() { ValidateModelPropertiesAndBuildRulesException(this); var parameters = new RulesBaseParams { ThrowException = false }; RulesException.ErrorMessages.Add("This is a fake error message"); RulesException.ErrorFor(x => x.Value, "This is a fake error"); var rulesExceptionCollection = ValidateModelPropertiesAndBuildRulesExceptionCollection <RulesBaseParams>(this, parameters); rulesExceptionCollection.ThrowException(); }