Пример #1
0
    def clean_name_ipv6(self):

        if self.cleaned_data['name_ipv6'] and ' ' in self.cleaned_data['name_ipv6']:
            raise forms.ValidationError(
                'O nome do template não deve conter espaços')
        elif self.cleaned_data['name_ipv6'] and not check_regex(self.cleaned_data['name_ipv6'], "^[a-zA-Z0-9_.-]+$"):
            raise forms.ValidationError(
                'Nome do template contém caracteres inválidos.')

        return self.cleaned_data['name_ipv6']
Пример #2
0
    def clean_name(self):

        if self.cleaned_data['name'] and ' ' in self.cleaned_data['name']:
            raise forms.ValidationError(
                'O nome do template não deve conter espaços')
        elif self.cleaned_data['name'] and not check_regex(
                self.cleaned_data['name'], "^[a-zA-Z0-9_.-]+$"):
            raise forms.ValidationError(
                'Nome do template contém caracteres inválidos.')

        return self.cleaned_data['name']
Пример #3
0
    def clean_acl_path(self):
        # valida acl_path
        if check_regex(self.cleaned_data['acl_path'], r'^.*[\\\\:*?"<>|].*$'):
            raise forms.ValidationError('Caracteres inválidos.')

        path = self.cleaned_data['acl_path']
        if path:
            try:
                while path[0] == "/":
                    path = path[1:]

                while path[-1] == "/":
                    path = path[:-1]
            except IndexError:
                raise forms.ValidationError('Path inválido')
        # valida acl_path

        return self.cleaned_data['acl_path']
Пример #4
0
    def clean_type_option(self):
        if not check_regex(self.cleaned_data['type_option'], REGEX_TEXT):
            raise forms.ValidationError('Caracteres inválidos.')

        return self.cleaned_data['type_option']
Пример #5
0
    def clean_nome(self):
        if not check_regex(self.cleaned_data['nome'], r'^[- a-zA-Z0-9]+$'):
            raise forms.ValidationError('Caracteres inválidos.')

        return self.cleaned_data['nome']
Пример #6
0
    def clean_nome(self):
        if not check_regex(self.cleaned_data['nome'], r'^[-a-zA-Z0-9 ]+$'):
            raise forms.ValidationError('Caracteres inválidos.')

        return self.cleaned_data['nome']
Пример #7
0
def is_valid_name(name):
    """
    Validates Name of Vlan
    """

    return check_regex(name, r'^[_+0-9a-zA-Z]/$')