From 35cc5b6e83d73a45d328e013996de4b5dc601ef4 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Mon, 18 Jul 2016 14:01:24 -0700 Subject: [PATCH] Use `IValidationAttributeAdapterProvider` more often - #5009 - don't create a `RequiredAttributeAdapter` directly --- .../Internal/DataAnnotationsClientModelValidatorProvider.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.DataAnnotations/Internal/DataAnnotationsClientModelValidatorProvider.cs b/src/Microsoft.AspNetCore.Mvc.DataAnnotations/Internal/DataAnnotationsClientModelValidatorProvider.cs index 5c1dc946f4..05d2aacac3 100644 --- a/src/Microsoft.AspNetCore.Mvc.DataAnnotations/Internal/DataAnnotationsClientModelValidatorProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.DataAnnotations/Internal/DataAnnotationsClientModelValidatorProvider.cs @@ -3,7 +3,6 @@ using System; using System.ComponentModel.DataAnnotations; -using System.Linq; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; @@ -99,7 +98,9 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal // Add a default '[Required]' validator for generating HTML if necessary. context.Results.Add(new ClientValidatorItem { - Validator = new RequiredAttributeAdapter(new RequiredAttribute(), stringLocalizer), + Validator = _validationAttributeAdapterProvider.GetAttributeAdapter( + new RequiredAttribute(), + stringLocalizer), IsReusable = true }); }