def clean(self, value):
     value = super(GoogleAnalyticsIDField, self).clean(value.strip())
     if not self.GOOGLE_ANALYTICS_ID_FORMAT.match(value):
         raise forms.ValidationError(
             'Invalid format. Google Analytics site tracking ID format is: UA-XXXXXX-YY.'
         )
     return value
예제 #2
0
 def clean(self, value):
     value = super(ClassNamesField, self).clean(value)
     class_names = filter(bool, map(lambda x: x.strip(), value.split(',')))
     for class_name in class_names:
         if not CLASS_NAME_FORMAT.match(class_name):
             raise forms.ValidationError(
                 '{0} is not a proper class name.'.format(class_name))
     return ', '.join(class_names)
예제 #3
0
 def clean(self, value):
     value = super(PositiveIntegerField, self).clean(value)
     try:
         val = int(value)
         assert val > 0
         return value
     except:
         raise forms.ValidationError('Please provide a positive integer')
예제 #4
0
 def clean(self, value):
     value = super(TagTypesField, self).clean(value)
     tag_types = filter(bool, map(lambda x: x.strip(), value.split(',')))
     for tag_type in tag_types:
         if not TAG_TYPE_FORMAT.match(tag_type):
             raise forms.ValidationError(
                 '{0} does not look like a proper HTML tag.'.format(
                     tag_type))
     return ', '.join(tag_types)