Adds a segment level validation key + updates tests

This commit is contained in:
Shannon
2020-04-17 16:12:04 +10:00
parent 99ad8ea773
commit 90b4d557c9
5 changed files with 77 additions and 17 deletions

View File

@@ -49,13 +49,15 @@ namespace Umbraco.Web
/// <param name="propertyAlias"></param>
/// <param name="culture">The culture for the property, if the property is invariant than this is empty</param>
internal static void AddPropertyError(this System.Web.Http.ModelBinding.ModelStateDictionary modelState,
ValidationResult result, string propertyAlias, string culture = "")
ValidationResult result, string propertyAlias, string culture = "", string segment = "")
{
if (culture == null)
culture = "";
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);
culture.IsNullOrWhiteSpace() ? "invariant" : culture,
// if the segment is null, we'll add the term 'null' as part of the key
segment.IsNullOrWhiteSpace() ? "null" : segment);
}
/// <summary>