Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Add TypeError to catch null inputs to numeric fields #180

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions vibora/schemas/extensions/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ cdef class Integer(Field):
raise ValidationError(error_code=Messages.MUST_BE_INTEGER, field=self.load_from)
try:
return int(value)
except ValueError:
except (ValueError, TypeError):
raise ValidationError(error_code=Messages.MUST_BE_INTEGER, field=self.load_from)


Expand All @@ -115,7 +115,7 @@ cdef class Number(Field):
raise ValidationError(error_code=Messages.MUST_BE_NUMBER, field=self.load_from)
try:
return float(value)
except ValueError:
except (ValueError, TypeError):
raise ValidationError(error_code=Messages.MUST_BE_NUMBER, field=self.load_from)


Expand Down