MCPcopy
hub / github.com/django/django / validate

Method validate

django/forms/fields.py:893–901  ·  view source on GitHub ↗

Validate that the input is in self.choices.

(self, value)

Source from the content-addressed store, hash-verified

891 return str(value)
892
893 def validate(self, value):
894 """Validate that the input is in self.choices."""
895 super().validate(value)
896 if value and not self.valid_value(value):
897 raise ValidationError(
898 self.error_messages["invalid_choice"],
899 code="invalid_choice",
900 params={"value": value},
901 )
902
903 def valid_value(self, value):
904 """Check to see if the provided value is a valid choice."""

Callers

nothing calls this directly

Calls 3

valid_valueMethod · 0.95
ValidationErrorClass · 0.90
validateMethod · 0.45

Tested by

no test coverage detected