예제 #1
0
 /// <summary>
 /// Adds the <see cref="ValidationResult"/> to the model state with the appropriate keys for property errors
 /// </summary>
 /// <param name="modelState"></param>
 /// <param name="result"></param>
 /// <param name="propertyAlias"></param>
 /// <param name="culture"></param>
 /// <param name="segment"></param>
 internal static void AddPropertyValidationError(this ModelStateDictionary modelState,
                                                 ValidationResult result,
                                                 string propertyAlias,
                                                 string culture = "",
                                                 string segment = "") =>
 modelState.AddValidationError(
     result,
     "_Properties",
     propertyAlias,
     //if the culture is null, we'll add the term 'invariant' as part of the key
     culture.IsNullOrWhiteSpace() ? "invariant" : culture,
     // if the segment is null, we'll add the term 'null' as part of the key
     segment.IsNullOrWhiteSpace() ? "null" : segment);