Skip to content
This repository was archived by the owner on Jun 18, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ public IEnumerable<ValidationResult> Validate(object rawValue, PreValueCollectio
if (value == null)
yield break;

IDataTypeService dataTypeService = ApplicationContext.Current.Services.DataTypeService;
for (var i = 0; i < value.Count; i++)
{
var o = value[i];
Expand All @@ -345,15 +346,17 @@ public IEnumerable<ValidationResult> Validate(object rawValue, PreValueCollectio
var propType = contentType.PropertyTypes.FirstOrDefault(x => x.Alias == propKey);
if (propType != null)
{
// It would be better to pass this off to the individual property editors
// to validate themselves and pass the result down, however a lot of the
// validation checking code in core seems to be internal so for now we'll
// just replicate the mandatory / regex validation checks ourselves.
// This does of course mean we will miss any custom validators a property
// editor may have registered by itself, and it also means we can only
// validate to a single depth so having a complex property editor in a
// doc type could get passed validation if it can't be validated from it's
// stored value alone.
PreValueCollection propPrevalues = dataTypeService.GetPreValuesCollectionByDataTypeId(propType.DataTypeDefinitionId);
PropertyEditor propertyEditor = PropertyEditorResolver.Current.GetByAlias(propType.PropertyEditorAlias);

foreach (IPropertyValidator validator in propertyEditor.ValueEditor.Validators)
{
foreach (ValidationResult result in validator.Validate(propValues[propKey], propPrevalues, propertyEditor))
{
result.ErrorMessage = "Item " + (i + 1) + " '" + propType.Name + "' " + result.ErrorMessage;
yield return result;
}
}

// Check mandatory
if (propType.Mandatory)
Expand Down