public ModelStateBuilder <T> SetFieldError(string fieldName, ProblemDetailsFieldType errorType, string message = null, Func <ProblemDetailsFieldType, bool> addOnly = null) { if (addOnly == null || addOnly(errorType)) { this._controller.ModelState.TryAddModelError(fieldName, ProblemDetailsFactory.GetComposeTypeAndErrorMessage(errorType, message)); } return(this); }
public static IRuleBuilderOptions <T, TProperty> WithMessage <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, ProblemDetailsFieldType type, string errorMessage) { rule.WithMessage(ProblemDetailsFactory.GetComposeTypeAndErrorMessage(type, errorMessage)); return(rule); }