Browse Source

Do not validate for primitive objects.

pull/5923/head
maliming 6 years ago
parent
commit
f8ff9c7ea5
  1. 14
      framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DataAnnotationObjectValidationContributor.cs

14
framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DataAnnotationObjectValidationContributor.cs

@ -45,12 +45,18 @@ namespace Volo.Abp.Validation
AddErrors(errors, validatingObject); AddErrors(errors, validatingObject);
//Validate items of enumerable //Validate items of enumerable
if (validatingObject is IEnumerable) if (validatingObject is IEnumerable enumerable)
{ {
if (!(validatingObject is IQueryable)) if (!(enumerable is IQueryable))
{ {
foreach (var item in (validatingObject as IEnumerable)) foreach (var item in enumerable)
{ {
//Do not recursively validate for primitive objects
if (TypeHelper.IsPrimitiveExtended(item.GetType()))
{
break;
}
ValidateObjectRecursively(errors, item, currentDepth + 1); ValidateObjectRecursively(errors, item, currentDepth + 1);
} }
} }
@ -124,4 +130,4 @@ namespace Volo.Abp.Validation
} }
} }
} }
} }

Loading…
Cancel
Save