using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Microsoft.AspNet.Mvc.ModelBinding { public class RequiredAttributeAdapter : DataAnnotationsModelValidator { public RequiredAttributeAdapter(RequiredAttribute attribute) : base(attribute) { } public override IEnumerable GetClientValidationRules( [NotNull] ClientModelValidationContext context) { var errorMessage = GetErrorMessage(context.ModelMetadata); return new[] { new ModelClientValidationRequiredRule(errorMessage) }; } } }