Added custom validation messages to property types: model, dto and migration, update via property type editing, display when content editing.

This commit is contained in:
Andy Butland
2019-06-26 14:37:02 +02:00
parent 56669b5c84
commit a90f0c4070
36 changed files with 254 additions and 66 deletions

View File

@@ -42,7 +42,9 @@ namespace Umbraco.Web.Models.Mapping
//add the validation information
dest.Validation.Mandatory = originalProp.PropertyType.Mandatory;
dest.Validation.MandatoryMessage = originalProp.PropertyType.MandatoryMessage;
dest.Validation.Pattern = originalProp.PropertyType.ValidationRegExp;
dest.Validation.PatternMessage = originalProp.PropertyType.ValidationRegExpMessage;
if (dest.PropertyEditor == null)
{

View File

@@ -21,7 +21,9 @@ namespace Umbraco.Web.Models.Mapping
base.Map(property, dest, context);
dest.IsRequired = property.PropertyType.Mandatory;
dest.IsRequiredMessage = property.PropertyType.MandatoryMessage;
dest.ValidationRegExp = property.PropertyType.ValidationRegExp;
dest.ValidationRegExpMessage = property.PropertyType.ValidationRegExpMessage;
dest.Description = property.PropertyType.Description;
dest.Label = property.PropertyType.Name;
dest.DataType = DataTypeService.GetDataType(property.PropertyType.DataTypeId);

View File

@@ -220,7 +220,9 @@ namespace Umbraco.Web.Models.Mapping
target.Name = source.Label;
target.DataTypeId = source.DataTypeId;
target.Mandatory = source.Validation.Mandatory;
target.MandatoryMessage = source.Validation.MandatoryMessage;
target.ValidationRegExp = source.Validation.Pattern;
target.ValidationRegExpMessage = source.Validation.PatternMessage;
target.Variations = source.AllowCultureVariant ? ContentVariation.Culture : ContentVariation.Nothing;
if (source.Id > 0)

View File

@@ -223,7 +223,13 @@ namespace Umbraco.Web.Models.Mapping
Alias = p.Alias,
Description = p.Description,
Editor = p.PropertyEditorAlias,
Validation = new PropertyTypeValidation {Mandatory = p.Mandatory, Pattern = p.ValidationRegExp},
Validation = new PropertyTypeValidation
{
Mandatory = p.Mandatory,
MandatoryMessage = p.MandatoryMessage,
Pattern = p.ValidationRegExp,
PatternMessage = p.ValidationRegExpMessage,
},
Label = p.Name,
View = propertyEditor.GetValueEditor().View,
Config = config,