def validate_username(self, username): if re.search(NON_ALPHANUMERIC_RE, username): raise ValidationError( 'Username should only contain letters, numbers and/or the underscore character.' ) existing = User.get_by(username=username) if existing and (self.is_create() or existing != self.instance): raise ValidationError('Sorry, that username is already taken.')
def validate_password(self, value): if not value or len(value) < 8: raise ValidationError( 'Password must be at least 8 characters long.')
def validate_email(self, email): existing = User.get_by(email=email) if existing and (self.is_create() or existing != self.instance): raise ValidationError('Sorry, that email is already taken.')
def validate_email(self, email): existing = NewsletterSubscribe.get_by(email=email) if existing and (self.is_create() or existing != self.instance): raise ValidationError( 'Sorry, you are already subscribed with that email.')