(self, value: str)
| 256 | return self.error.format(input=value) |
| 257 | |
| 258 | def __call__(self, value: str) -> str: |
| 259 | message = self._format_error(value) |
| 260 | |
| 261 | if not value or "@" not in value: |
| 262 | raise ValidationError(message) |
| 263 | |
| 264 | user_part, domain_part = value.rsplit("@", 1) |
| 265 | |
| 266 | if not self.USER_REGEX.match(user_part): |
| 267 | raise ValidationError(message) |
| 268 | |
| 269 | if domain_part not in self.DOMAIN_WHITELIST: |
| 270 | if not self.DOMAIN_REGEX.match(domain_part): |
| 271 | try: |
| 272 | domain_part = domain_part.encode("idna").decode("ascii") |
| 273 | except UnicodeError: |
| 274 | pass |
| 275 | else: |
| 276 | if self.DOMAIN_REGEX.match(domain_part): |
| 277 | return value |
| 278 | raise ValidationError(message) |
| 279 | |
| 280 | return value |
| 281 | |
| 282 | |
| 283 | class Range(Validator): |
nothing calls this directly
no test coverage detected