Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float validator fails on more that 3 digits after decimal separator #80

Open
hvelarde opened this issue Apr 27, 2018 · 1 comment
Open

Comments

@hvelarde
Copy link
Contributor

I have a couple of fields defined this way:

class IPin(model.Schema):
    """A Pin."""
    ...
    latitude = schema.Float(
        title=_(u'label_latitude', default=u'Latitude'),
        required=True,
        default=0.0,
    )

    longitude = schema.Float(
        title=_(u'label_longitude', default=u'Longitude'),
        required=True,
        default=0.0,
    )

the validator accepts a number like -12,345 but fails with something like -12,3456 with:

The entered value is not a valid decimal literal.
@rodfersou
Copy link
Contributor

This is the way the validation works now:

ipdb> value
u'400,5540'
ipdb> self.type
<type 'float'>
ipdb> self.formatter.parse(value)
*** NumberParseError: Not a valid number for this pattern u'#,##0.###;-#,##0.###'.

The generated regex is wrong, float type can have 53 bits of precision instead of just 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants