From 580d6a5be9748f6ddf59b5233559b4d685b07e7a Mon Sep 17 00:00:00 2001 From: syuparn Date: Sun, 30 Mar 2025 11:33:45 +0900 Subject: [PATCH] add regex validator for project test name --- blawx/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blawx/models.py b/blawx/models.py index 971678d8..6f9c5fc8 100644 --- a/blawx/models.py +++ b/blawx/models.py @@ -2,6 +2,7 @@ from django.dispatch import receiver from django.db import models from django.contrib.auth.models import User +from django.core.validators import RegexValidator from .parse_an import generate_tree from cobalt.hierarchical import Act from clean.clean import generate_akn @@ -54,7 +55,8 @@ class Meta: class BlawxTest(models.Model): ruledoc = models.ForeignKey(RuleDoc, related_name='tests', on_delete=models.CASCADE) - test_name = models.CharField(max_length=200) + validate_test_name = RegexValidator(regex="^[-a-zA-Z0-9_]+$",message="Test names cannot have spaces or special characters.") + test_name = models.CharField(max_length=200,validators=[validate_test_name]) xml_content = models.TextField(default="",blank=True) scasp_encoding = models.TextField(default="",blank=True) tutorial = models.TextField(default="",blank=True)