diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index afcc052cd..5fa26f0fd 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -132,15 +132,21 @@ class NormaJuridicaForm(ModelForm): if not self.is_valid(): return cleaned_data + + import re + has_digits = re.sub('[^0-9]', '', cleaned_data['numero']) + if not has_digits: + raise ValidationError('Número de norma não pode conter somente letras') + if self.instance.numero != cleaned_data['numero']: norma = NormaJuridica.objects.filter(ano=cleaned_data['ano'], - numero=cleaned_data['numero'], - tipo=cleaned_data['tipo']).exists() + numero=cleaned_data['numero'], + tipo=cleaned_data['tipo']).exists() if norma: raise ValidationError("Já existe uma norma de mesmo Tipo, Ano " "e Número no sistema") if (cleaned_data['tipo_materia'] and - cleaned_data['numero_materia'] and + cleaned_data['numero_materia'] and cleaned_data['ano_materia']): try: materia = MateriaLegislativa.objects.get(