(text)
Validates form input for tags
Validates form input for tags
Validates form input for tags
def valid_tag(text):
    "Validates form input for tags"

    tag_val = text.replace(',', ' ').split()

    if len(tag_val) > MAX_TAGS:
        return forms.ValidationError("Maximum number of tags reached.")

    if settings.STRICT_TAGS:
        pattern = r'^[A-Za-z0-9-._]+$'
        for tag in tag_val:
            match = re.match(pattern, tag)
            if not match:
                raise forms.ValidationError(f'Invalid characters in tag: {tag}')
def valid_tag ( text ) : tag_val = text . replace ( ',' , ' ' ) . split ( ) if len ( tag_val ) > MAX_TAGS : return forms . ValidationError ( "Maximum number of tags reached." ) if settings . STRICT_TAGS : pattern = r'^[A-Za-z0-9-._]+$' for tag in tag_val : match = re . match ( pattern , tag ) if not match : raise forms . ValidationError ( f'Invalid characters in tag: {tag}' )