emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

Validation decimal fields #203

Closed josejachuf closed 7 years ago

josejachuf commented 7 years ago

The validators gt, gte, lt and lte only work for integers? I have a model with a decimal field and validation fails

if validation is

validation = {        
    'fdecimal': {'gte': 0}
 }

def _gt(self, val1, val2, eq=False): if eq: return val1 >= val2 return val1 > val2

TypeError: '>=' not supported between instances of 'str' and 'int'

if validation is

validation = {        
    'fdecimal': {'gte': 0}
 }

def _gt(self, val1, val2, eq=False): if eq: return val1 >= val2 return val1 > val2

TypeError: '>=' not supported between instances of 'str' and 'int'

if validation is

validation = {        
    'fdecimal': {'gte': decimal.Decimal('0')}
 }

TypeError: '>=' not supported between instances of 'str' and 'decimal.Decimal'

gi0baro commented 7 years ago

@josejachuf this is fixed in the current master. I will probably release also a bugfix version of the 1.1 later today, 'cause I'm not ready to release 1.2 yet.

gi0baro commented 7 years ago

@josejachuf this is published also in 1.1.2