blob: b5f22cd4b9d53b0e52d18b531be9f849b9275e4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
from django.core.exceptions import ValidationError
country_validator_choices = [
('europe', 'Must be from European country'),
]
def validate_country(validator, country):
if not validator:
return
if validator == 'europe':
if not hasattr(country, 'europecountry'):
raise ValidationError("Membership is available to people living in geographical Europe.")
return
raise ValidationError("Invalid validator '{}' configured".format(validator))
|