Skip to content

CustomField.validate does not check the length of a text field #9687

@PieterL75

Description

@PieterL75

NetBox version

v3.2.5

Python version

3.9

Steps to Reproduce

  1. create a custom field of the type 'text'
  2. use the API to update that text field with a string > 255 characters

Expected Behavior

A validation error should be thrown, as custom TEXT fields should be limited to 255 characters

Observed Behavior

The length validation is only done in the 'form' and not in validate()

https://github.com/netbox-community/netbox/blob/develop/netbox/extras/models/customfields.py#L457-L462

This part should also check the length of a TEXT custom field:

                if self.type == CustomFieldTypeChoices.TYPE_TEXT and len(value) > 255:
                    raise ValidationError(f"Value cannot contain more than 255 characters")

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions