diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj b/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj
index d560c66738..f7812e207f 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj
@@ -71,6 +71,9 @@
+
+
+
@@ -89,8 +92,11 @@
+
+
+
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DataAnnotationsModelValidatorProvider.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DataAnnotationsModelValidatorProvider.cs
index 58be51090f..9a2b5e26c3 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DataAnnotationsModelValidatorProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DataAnnotationsModelValidatorProvider.cs
@@ -86,6 +86,18 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
AddValidationAttributeAdapter(dict, typeof(CompareAttribute),
(attribute) => new CompareAttributeAdapter((CompareAttribute)attribute));
+ AddValidationAttributeAdapter(dict, typeof(RequiredAttribute),
+ (attribute) => new RequiredAttributeAdapter((RequiredAttribute)attribute));
+
+ AddValidationAttributeAdapter(dict, typeof(RangeAttribute),
+ (attribute) => new RangeAttributeAdapter((RangeAttribute)attribute));
+
+ AddValidationAttributeAdapter(dict, typeof(StringLengthAttribute),
+ (attribute) => new StringLengthAttributeAdapter((StringLengthAttribute)attribute));
+
+ AddDataTypeAttributeAdapter(dict, typeof(CreditCardAttribute), "creditcard");
+ AddDataTypeAttributeAdapter(dict, typeof(EmailAddressAttribute), "email");
+ AddDataTypeAttributeAdapter(dict, typeof(PhoneAttribute), "phone");
AddDataTypeAttributeAdapter(dict, typeof(UrlAttribute), "url");
return dict;
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationRangeRule.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationRangeRule.cs
new file mode 100644
index 0000000000..26e610e9ec
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationRangeRule.cs
@@ -0,0 +1,18 @@
+namespace Microsoft.AspNet.Mvc.ModelBinding
+{
+ public class ModelClientValidationRangeRule : ModelClientValidationRule
+ {
+ private const string RangeValidationType = "range";
+ private const string MinValidationParameter = "min";
+ private const string MaxValidationParameter = "max";
+
+ public ModelClientValidationRangeRule([NotNull] string errorMessage,
+ [NotNull] object minValue,
+ [NotNull] object maxValue)
+ : base(RangeValidationType, errorMessage)
+ {
+ ValidationParameters[MinValidationParameter] = minValue;
+ ValidationParameters[MaxValidationParameter] = maxValue;
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationRequiredRule.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationRequiredRule.cs
new file mode 100644
index 0000000000..6784b94425
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationRequiredRule.cs
@@ -0,0 +1,12 @@
+namespace Microsoft.AspNet.Mvc.ModelBinding
+{
+ public class ModelClientValidationRequiredRule : ModelClientValidationRule
+ {
+ private const string RequiredValidationType = "required";
+
+ public ModelClientValidationRequiredRule(string errorMessage) :
+ base(RequiredValidationType, errorMessage)
+ {
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationStringLengthRule.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationStringLengthRule.cs
new file mode 100644
index 0000000000..c0131694bb
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/ModelClientValidationStringLengthRule.cs
@@ -0,0 +1,23 @@
+namespace Microsoft.AspNet.Mvc.ModelBinding
+{
+ public class ModelClientValidationStringLengthRule : ModelClientValidationRule
+ {
+ private const string LengthValidationType = "length";
+ private const string MinValidationParameter = "min";
+ private const string MaxValidationParameter = "max";
+
+ public ModelClientValidationStringLengthRule(string errorMessage, int minimumLength, int maximumLength)
+ : base(LengthValidationType, errorMessage)
+ {
+ if (minimumLength != 0)
+ {
+ ValidationParameters[MinValidationParameter] = minimumLength;
+ }
+
+ if (maximumLength != int.MaxValue)
+ {
+ ValidationParameters[MaxValidationParameter] = maximumLength;
+ }
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/RangeAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/RangeAttributeAdapter.cs
new file mode 100644
index 0000000000..8e9e1d559d
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/RangeAttributeAdapter.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace Microsoft.AspNet.Mvc.ModelBinding
+{
+ public class RangeAttributeAdapter : DataAnnotationsModelValidator
+ {
+ public RangeAttributeAdapter(RangeAttribute attribute)
+ : base(attribute)
+ {
+ }
+
+ public override IEnumerable GetClientValidationRules(
+ [NotNull] ClientModelValidationContext context)
+ {
+ var errorMessage = GetErrorMessage(context.ModelMetadata);
+ return new[] { new ModelClientValidationRangeRule(errorMessage, Attribute.Minimum, Attribute.Maximum) };
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/RequiredAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/RequiredAttributeAdapter.cs
new file mode 100644
index 0000000000..5074114c0c
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/RequiredAttributeAdapter.cs
@@ -0,0 +1,20 @@
+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) };
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/StringLengthAttributeAdapter.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/StringLengthAttributeAdapter.cs
new file mode 100644
index 0000000000..f261891b40
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/StringLengthAttributeAdapter.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace Microsoft.AspNet.Mvc.ModelBinding
+{
+ public class StringLengthAttributeAdapter : DataAnnotationsModelValidator
+ {
+ public StringLengthAttributeAdapter(StringLengthAttribute attribute)
+ : base(attribute)
+ {
+ }
+
+ public override IEnumerable GetClientValidationRules(
+ [NotNull] ClientModelValidationContext context)
+ {
+ var errorMessage = GetErrorMessage(context.ModelMetadata);
+ return new[] { new ModelClientValidationStringLengthRule(errorMessage,
+ Attribute.MinimumLength,
+ Attribute.MaximumLength) };
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Microsoft.AspNet.Mvc.ModelBinding.Test.kproj b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Microsoft.AspNet.Mvc.ModelBinding.Test.kproj
index 18fcdd0d84..26bca548b4 100644
--- a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Microsoft.AspNet.Mvc.ModelBinding.Test.kproj
+++ b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Microsoft.AspNet.Mvc.ModelBinding.Test.kproj
@@ -39,6 +39,9 @@
+
+
+
diff --git a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Validation/DataAnnotationsModelValidatorProviderTest.cs b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Validation/DataAnnotationsModelValidatorProviderTest.cs
index d81fff46dc..c4a71adf62 100644
--- a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Validation/DataAnnotationsModelValidatorProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Validation/DataAnnotationsModelValidatorProviderTest.cs
@@ -13,51 +13,74 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
private readonly DataAnnotationsModelMetadataProvider _metadataProvider = new DataAnnotationsModelMetadataProvider();
- public static IEnumerable