Update customfields.py

Add type check for custom fields with "text" type
This commit is contained in:
avisom 2021-06-21 17:19:53 +03:00 committed by GitHub
parent 607039f043
commit 5cc4fa8eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,6 +281,8 @@ class CustomField(BigIDModel):
# Validate text field
if self.type == CustomFieldTypeChoices.TYPE_TEXT and self.validation_regex:
if type(value) is not str:
raise ValidationError("Value must be a string.")
if not re.match(self.validation_regex, value):
raise ValidationError(f"Value must match regex '{self.validation_regex}'")