def validator(form, value): items = value.split() if len(items) > 1: raise ValidationError(_(u'You have to enter a valid net address.')) items = items[0].split(':') if len(items) not in (1, 2): raise ValidationError(_(u'You have to enter a valid net address.')) elif len(items) == 2 and not items[1].isdigit(): raise ValidationError(_(u'The port has to be numeric'))
def validator(form, value): if '<' in value or '>' in value: raise ValidationError(_(u'Invalid character, < or > are not allowed.')) if value == '/': raise ValidationError(_(u'URL prefix must not be a sole slash.')) if value: if value[:1] != '/': raise ValidationError(_(u'URL prefix must start with a slash.')) if value[-1:] == '/': raise ValidationError(_(u'URL prefix must not end with a slash.'))
def validator(form, value): if not value.strip(): raise ValidationError(_(u'The text must not be empty.'))
def validator(form, value): if len(value) > 200: raise ValidationError(_(u'The slug is too long')) elif value.startswith('/'): raise ValidationError(_(u'The slug must not start with a slash'))