mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 19:36:26 -06:00
Update customfields.py
Add type check for custom fields with "text" type
This commit is contained in:
parent
607039f043
commit
5cc4fa8eee
@ -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}'")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user