Add the ability to require unique input to custom field #5858

Closed
opened 2025-12-29 19:33:32 +01:00 by adam · 4 comments
Owner

Originally created by @K0HAX on GitHub (Dec 30, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.1.1

Feature type

New functionality

Proposed functionality

Currently, custom fields are never checked for unique content.
It would be nice to be able to add checks for uniqueness inside custom fields as an option to that specific custom field.

Use case

I am using custom fields to add a unique name similar to a Common Language Location Identifiers (CLLI) name for each site.
No two sites should have the same unique name from this field.

Database changes

The database would probably need a new column to track if the custom field needs a uniqueness check, and in the general case, what the scope of the uniqueness check should be (example: global, regional, site, none).

External dependencies

None

Originally created by @K0HAX on GitHub (Dec 30, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.1.1 ### Feature type New functionality ### Proposed functionality Currently, custom fields are never checked for unique content. It would be nice to be able to add checks for uniqueness inside custom fields as an option to that specific custom field. ### Use case I am using custom fields to add a unique name similar to a Common Language Location Identifiers (CLLI) name for each site. No two sites should have the same unique name from this field. ### Database changes The database would probably need a new column to track if the custom field needs a uniqueness check, and in the general case, what the scope of the uniqueness check should be (example: global, regional, site, none). ### External dependencies None
adam added the status: acceptedtype: featurecomplexity: medium labels 2025-12-29 19:33:32 +01:00
adam closed this issue 2025-12-29 19:33:33 +01:00
Author
Owner

@sdktr commented on GitHub (Jan 5, 2022):

Maybe this can already be solved with a 'custom validator'?

The uniqueness scoping that you seam to have in mind are not easily applied to all other netbox users imo

@sdktr commented on GitHub (Jan 5, 2022): Maybe this can already be solved with a 'custom validator'? The uniqueness scoping that you seam to have in mind are not easily applied to all other netbox users imo
Author
Owner

@DanSheps commented on GitHub (Jan 5, 2022):

As pointed out, this should be solvable with a custom validator.

The logic implemented would be the same as we would implement. It would need to be a custom validation class, so perhaps adding a new option to the base custom validation of "unique" might be the best way forward here.

@DanSheps commented on GitHub (Jan 5, 2022): As pointed out, this should be solvable with a custom validator. The logic implemented would be the same as we would implement. It would need to be a custom validation class, so perhaps adding a new option to the base custom validation of "unique" might be the best way forward here.
Author
Owner

@jeremystretch commented on GitHub (Jan 14, 2022):

Maybe this can already be solved with a 'custom validator'?

It can be, although custom validation doesn't currently support uniqueness checking as a standard validator: It would require the introduction of a custom class. (This might be an FR on its own.)

I do think there's value in providing optional uniqueness enforcement for custom fields, though, just as we provide min/max and regex validation. Actually enforcing the validation could get tricky, though.

I'm going to tag this for milestone assignment as I think it's worth exploring. If it ends up not being feasible, so be it.

@jeremystretch commented on GitHub (Jan 14, 2022): > Maybe this can already be solved with a 'custom validator'? It can be, although [custom validation](https://netbox.readthedocs.io/en/stable/customization/custom-validation/) doesn't currently support uniqueness checking as a standard validator: It would require the introduction of a custom class. (This might be an FR on its own.) I do think there's value in providing optional uniqueness enforcement for custom fields, though, just as we provide min/max and regex validation. Actually enforcing the validation could get tricky, though. I'm going to tag this for milestone assignment as I think it's worth exploring. If it ends up not being feasible, so be it.
Author
Owner

@ryanmerolle commented on GitHub (Apr 25, 2023):

This could be a good candidate for 3.6

@ryanmerolle commented on GitHub (Apr 25, 2023): This could be a good candidate for 3.6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5858