srkirkland / DataAnnotationsExtensions

Validation extensions for DataAnnotations, including optional MVC client validation implementations
https://dataannotationsextensions.apphb.com/
BSD 3-Clause "New" or "Revised" License
308 stars 86 forks source link

MaxAttribute Incurrectly flags values as not in range #63

Closed Vyeche closed 8 years ago

Vyeche commented 10 years ago

I set a max range of 110000, but it flags anything that has values of 11345 etc, it works if it matches 110000 etc. Maybe the regex or whatever your using should be: "^0*(110,?000|((10[0-9]|[1-9][0-9]|[1-9]),?[0-9]{3})|([1-9][0-9]{2}|[1-9][0-9]|[1-9]))$

I'm passing values like 2500.00 or 231.00

They are decimal type and currency in the database.

EDIT: After some digging on jquery.validate.js it appears that they already provide a max and min attribute and it uses there attribute to validate. However, it seems to fail when the value looks like "42.0000" if using currency or decimal.

If I take away the Quotes around it, then it works. I don't understand why this is happening.

// http://jqueryvalidation.org/max-method/ max: function( value, element, param ) { return this.optional( element ) || value <= param; },

srkirkland commented 8 years ago

Closing since i can't reproduce -- I made a decimal type with a Max[110000] attribute on it and validation worked just fine.