Enhance Type Integer values validation #5726

Closed
opened 2025-12-29 19:31:56 +01:00 by adam · 2 comments
Owner

Originally created by @damiankaczkowski on GitHub (Dec 3, 2021).

NetBox version

3.0.11

Feature type

New functionality

Proposed functionality

Enhance Type Integer values validation by allowing Validation regex or develop some other mechanism to narrow available selection like shown in the use case below.

Currently when I try to use Validation regex for Type Integer I get error like this:
"Regular expression validation is supported only for text and URL fields"

Use case

To narrow available value range. For example:

  1. Using validation regex:
    Minimum value: 514
    Maximum value: 65535
    Validation regex: ^(514|[1-6]\d\d\d+)$

  2. Or maybe develop something like this for Type Integer values...:
    Minimum value: 1024
    Maximum value: 65535
    Additional values: 514,515

  3. Or maybe even better and simpler...:
    Integer validation: 514,515,1024-65535

Third option would be best I think.

Database changes

No response

External dependencies

No response

Originally created by @damiankaczkowski on GitHub (Dec 3, 2021). ### NetBox version 3.0.11 ### Feature type New functionality ### Proposed functionality Enhance Type Integer values validation by allowing Validation regex or develop some other mechanism to narrow available selection like shown in the use case below. Currently when I try to use Validation regex for Type Integer I get error like this: "Regular expression validation is supported only for text and URL fields" ### Use case To narrow available value range. For example: 1. Using validation regex: Minimum value: 514 Maximum value: 65535 Validation regex: ^(514|[1-6]\d\d\d+)$ 2. Or maybe develop something like this for Type Integer values...: Minimum value: 1024 Maximum value: 65535 Additional values: 514,515 3. Or maybe even better and simpler...: Integer validation: 514,515,1024-65535 Third option would be best I think. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 19:31:56 +01:00
adam closed this issue 2025-12-29 19:31:57 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 3, 2021):

I'm not sure what you're trying to accomplish here, but you have three options available:

  1. Use an integer custom field with minimum and/or maximum values.
  2. Use a custom selection field with pre-defined values.
  3. Use a text custom field with regular expressions.

Regular expressions apply only to strings, so the proposed feature isn't feasible anyway.

@jeremystretch commented on GitHub (Dec 3, 2021): I'm not sure what you're trying to accomplish here, but you have three options available: 1. Use an integer custom field with minimum and/or maximum values. 2. Use a custom selection field with pre-defined values. 3. Use a text custom field with regular expressions. Regular expressions apply only to strings, so the proposed feature isn't feasible anyway.
Author
Owner

@damiankaczkowski commented on GitHub (Dec 3, 2021):

What I tried to accomplish is to give netbox user/admin rights to input tcp/udp port number >1024 into form and forbid ability to input ports <1024 (which are system restricted ports and generally should not be used besides the cases when we use port number that is registered by iana for particular service). So we need a rule with range for example 1024-65535 but with the addition of one or two ports that are known for particular service and are registered by iana (for example in case of syslog its port 514): https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml

The syslog is just an example. Such a rule should be useful for many other cases when one needs a range and few single values or two or more ranges.

For example such validation definition would be required and is more flexible for many custom cases and the case above I think.
Integer validation: 514,1024-65535

I know that there are config contexts but they does not work in my case. We need custom filed with such validation rules - a range + few single values.

Please reconsider. It's a valid use case imo. But I understand if not its feasible for you. Greets.

@damiankaczkowski commented on GitHub (Dec 3, 2021): What I tried to accomplish is to give netbox user/admin rights to input tcp/udp port number >1024 into form and forbid ability to input ports <1024 (which are system restricted ports and generally should not be used besides the cases when we use port number that is registered by iana for particular service). So we need a rule with range for example 1024-65535 but with the addition of one or two ports that are known for particular service and are registered by iana (for example in case of syslog its port 514): https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml The syslog is just an example. Such a rule should be useful for many other cases when one needs a range and few single values or two or more ranges. For example such validation definition would be required and is more flexible for many custom cases and the case above I think. Integer validation: 514,1024-65535 I know that there are config contexts but they does not work in my case. We need custom filed with such validation rules - a range + few single values. Please reconsider. It's a valid use case imo. But I understand if not its feasible for you. Greets.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5726