#1111 closed defect (fixed)
Documentation Error in custom validator example
| Reported by: | Owned by: | Jacob | |
|---|---|---|---|
| Component: | Documentation | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
From the documentation as it is at the time of this bug report:
from django.core import validators, formfields
class ContactManipulator(formfields.Manipulator):
def __init__(self):
self.fields = (
# ... snip fields as above ...
formfields.EmailField(field_name="to", validator_list=[self.isValidToAddress])
)
def isValidToAddress(self, field_data, all_data):
if not field_data.endswith("@example.com"):
raise ValidationError("You can only send messages to example.com e-mail addresses.")
Calls to ValidationError be written as such:
raise validators.ValidationError(...)
ValidationError by itself is undefined.
Note:
See TracTickets
for help on using tickets.
(In [1776]) Fixed #1111 -- Fixed bug in docs/forms.txt. Thanks, afarhham