From 5cc4fa8eeec75aa60c39aaeda6ca8b5afd9b2a5a Mon Sep 17 00:00:00 2001 From: avisom Date: Mon, 21 Jun 2021 17:19:53 +0300 Subject: [PATCH] Update customfields.py Add type check for custom fields with "text" type --- netbox/extras/models/customfields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py index b88c73531..af7dee579 100644 --- a/netbox/extras/models/customfields.py +++ b/netbox/extras/models/customfields.py @@ -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}'")