Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
K0HAX opened this issue Dec 30, 2021 · 4 comments
Closed

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

K0HAX opened this issue Dec 30, 2021 · 4 comments
Assignees
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@K0HAX
Copy link

K0HAX commented Dec 30, 2021

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

@K0HAX K0HAX added the type: feature Introduction of new functionality to the application label Dec 30, 2021
@sdktr
Copy link
Contributor

sdktr commented 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

@DanSheps
Copy link
Member

DanSheps commented 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 DanSheps added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Jan 5, 2022
@jeremystretch
Copy link
Member

jeremystretch commented 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 jeremystretch added needs milestone Awaiting prioritization for inclusion with a future NetBox release and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jan 14, 2022
@ryanmerolle
Copy link
Contributor

This could be a good candidate for 3.6

@jeremystretch jeremystretch added status: backlog Awaiting selection for work complexity: medium Requires a substantial but not unusual amount of effort to implement labels May 21, 2024
@jeffgdotorg jeffgdotorg added this to the v4.1 milestone May 31, 2024
@jeffgdotorg jeffgdotorg removed the needs milestone Awaiting prioritization for inclusion with a future NetBox release label Jun 7, 2024
@jeremystretch jeremystretch self-assigned this Jun 19, 2024
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: backlog Awaiting selection for work labels Jun 19, 2024
jeremystretch added a commit that referenced this issue Jun 25, 2024
* Closes #8198: Implement ability to enforce custom field uniqueness

* Add missing form fields & table columns for validation attributes

* Remove obsolete code
jeremystretch added a commit that referenced this issue Jul 30, 2024
jeremystretch added a commit that referenced this issue Aug 30, 2024
* #8198: Rename CustomField.validation_unique to unique

* Update CustomField model documentation
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

6 participants