Helper method to make a `ValidationError` with an error message from ``self.error_messages``.
(self, key: str, **kwargs)
| 286 | return And(*self.validators) |
| 287 | |
| 288 | def make_error(self, key: str, **kwargs) -> ValidationError: |
| 289 | """Helper method to make a `ValidationError` with an error message |
| 290 | from ``self.error_messages``. |
| 291 | """ |
| 292 | try: |
| 293 | msg = self.error_messages[key] |
| 294 | except KeyError as error: |
| 295 | class_name = self.__class__.__name__ |
| 296 | message = ( |
| 297 | f"ValidationError raised by `{class_name}`, but error key `{key}` does " |
| 298 | "not exist in the `error_messages` dictionary." |
| 299 | ) |
| 300 | raise AssertionError(message) from error |
| 301 | if isinstance(msg, (str, bytes)): |
| 302 | msg = msg.format(**kwargs) |
| 303 | return ValidationError(msg) |
| 304 | |
| 305 | def _validate_missing(self, value: typing.Any) -> None: |
| 306 | """Validate missing values. Raise a :exc:`ValidationError` if |