Skip to content

Form validation of mal-formed uuid is broken #31

@julienaubert

Description

@julienaubert

While working on #30, I wrote this test:

class FormUUIDField(TestCase):

    def test_formfield_error(self):
        form = ManualUUIDForm({'uuid': '123'})
        self.assertFalse(form.is_valid())

This test fails. I did not check much, but I think the reason/fix is this:

    1. to_python should raise ValidationError (i.e. wrap the StringUUID in a try except ValueError and re-raise an appropriate ValidationError)
    1. the formfield method gives CharField as form_class, this has the effect that the to_python that is called is the CharField, this should change so that the correct to_python is called.

I excluded the tests from that PR #30, as this is broken in the current version and can be fixed independently of #30.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions