// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Microsoft.AspNet.Mvc.ModelBinding.Validation { public class RangeAttributeAdapter : DataAnnotationsClientModelValidator { public RangeAttributeAdapter(RangeAttribute attribute) : base(attribute) { } public override IEnumerable GetClientValidationRules( ClientModelValidationContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var errorMessage = GetErrorMessage(context.ModelMetadata); return new[] { new ModelClientValidationRangeRule(errorMessage, Attribute.Minimum, Attribute.Maximum) }; } } }