1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #5558: Fix regex validation support for custom URL fields

This commit is contained in:
Jeremy Stretch
2020-12-31 10:21:01 -05:00
parent 7873952e7a
commit af3c4905ea
2 changed files with 3 additions and 1 deletions

View File

@ -196,7 +196,8 @@ class CustomField(models.Model):
})
# Regex validation can be set only for text fields
if self.validation_regex and self.type != CustomFieldTypeChoices.TYPE_TEXT:
regex_types = (CustomFieldTypeChoices.TYPE_TEXT, CustomFieldTypeChoices.TYPE_URL)
if self.validation_regex and self.type not in regex_types:
raise ValidationError({
'validation_regex': "Regular expression validation is supported only for text and URL fields"
})