jpmckinney / validictory

🎓 deprecated general purpose python data validator
Other
240 stars 57 forks source link

Allow Decimal to be used in number #38

Closed eisensheng closed 12 years ago

eisensheng commented 12 years ago

Json parsers allow a custom type to be used for parsing float values. It is common practice to use Decimal as float storage to prevent precision loss.

Example:

    parsed_data = json.loads(raw_data, parse_float=Decimal)
    validictory.validate(parsed_data, SCHEMA)

would fail horrible with now option to allow Decimal to be used.

A better approach would be to extend the API and allow users to specify which types are allowed in which case. This commit fixes my current issue with Decimal though.

jamesturk commented 12 years ago

thanks for this, what name would you like to be credited under?