Format the value or raise a :exc:`ValidationError` if an error occurs.
(self, value: typing.Any)
| 979 | return self.num_type(value) # type: ignore[call-arg] |
| 980 | |
| 981 | def _validated(self, value: typing.Any) -> _NumT: |
| 982 | """Format the value or raise a :exc:`ValidationError` if an error occurs.""" |
| 983 | # (value is True or value is False) is ~5x faster than isinstance(value, bool) |
| 984 | if value is True or value is False: |
| 985 | raise self.make_error("invalid", input=value) |
| 986 | try: |
| 987 | return self._format_num(value) |
| 988 | except (TypeError, ValueError) as error: |
| 989 | raise self.make_error("invalid", input=value) from error |
| 990 | except OverflowError as error: |
| 991 | raise self.make_error("too_large", input=value) from error |
| 992 | |
| 993 | def _to_string(self, value: _NumT) -> str: |
| 994 | return str(value) |
no test coverage detected