timsavage / django-ajax-forms

Automatically exported from code.google.com/p/django-ajax-forms
Other
1 stars 1 forks source link

max_value rule not matching Django validation with DecimalField #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set a max_value on DecimalField
2. Field is passed by JavaScript but fails django's validation

It looks like this might be a problem in Django. Investigation is required.

Original issue reported on code.google.com by Sle...@gmail.com on 24 Jan 2009 at 7:10

GoogleCodeExporter commented 9 years ago

Original comment by Sle...@gmail.com on 25 Jan 2009 at 2:39

GoogleCodeExporter commented 9 years ago

Original comment by Sle...@gmail.com on 26 Jan 2009 at 1:08

GoogleCodeExporter commented 9 years ago
With a DecimalField the min and max values must be passed in as decimal.Decimal
classes. There is no type checking on the passed value. A float will be 
accepted in
your form but (Decimal('12.1') > 13) will return true and validation fails.

Some additional casting was required as the jsonencoder got itself into a 
continuous
loop attemping to serialize a decimal.Decimal.

ajax_fields.AjaxField.add_rule now has a cast option that accepts a function to 
do
type conversion on the rule value.

Original comment by Sle...@gmail.com on 16 Mar 2009 at 12:09