Skip to content

Commit

Permalink
fix: Validate source IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jun 11, 2024
1 parent 7d1ca1f commit 61bf33a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion process/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db import models
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -59,7 +60,10 @@ class Transform(models.TextChoices):
UPGRADE_10_11 = "upgrade-1-0-to-1-1", _("Upgrade from 1.0 to 1.1 ")

# Identification
source_id = models.TextField(help_text=_("If sourced from Scrapy, this should be the name of the spider."))
source_id = models.TextField(
validators=[RegexValidator(r"^([a-z]+_)*[a-z]+$", _("source_id must be letters and underscores only"))],
help_text=_("If sourced from Scrapy, this should be the name of the spider."),
)
data_version = models.DateTimeField(help_text=_("The time at which the files were retrieved (not loaded)."))
sample = models.BooleanField(default=False)

Expand Down

0 comments on commit 61bf33a

Please sign in to comment.