Apply field validator to custom fields #471

Closed
opened 2025-12-29 16:22:29 +01:00 by adam · 6 comments
Owner

Originally created by @eronlloyd on GitHub (Oct 9, 2016).

Originally assigned to: @jeremystretch on GitHub.

I'm experimenting with custom fields on devices to create a code to help locate devices in our facilities. Once a convention is defined for custom fields, it would be great to be able to do input validation on them to make sure they comply. It seems possible to create validators, such as a RegexValidator, and apply it during form.clean() to handle something like this.

Originally created by @eronlloyd on GitHub (Oct 9, 2016). Originally assigned to: @jeremystretch on GitHub. I'm experimenting with custom fields on devices to create a code to help locate devices in our facilities. Once a convention is defined for custom fields, it would be great to be able to do input validation on them to make sure they comply. It seems possible to create validators, such as a RegexValidator, and apply it during form.clean() to handle something like this.
adam added the status: acceptedtype: feature labels 2025-12-29 16:22:29 +01:00
adam closed this issue 2025-12-29 16:22:29 +01:00
Author
Owner

@darcynz commented on GitHub (May 8, 2019):

Being able to apply input validation (with regex) would be great for custom fields but also fields in general. Would help minimize input error at the source.

@darcynz commented on GitHub (May 8, 2019): Being able to apply input validation (with regex) would be great for custom fields but also fields in general. Would help minimize input error at the source.
Author
Owner

@tomehb commented on GitHub (Mar 12, 2020):

I strongly agree with this; we are just started populating a Netbox instance with our DC, IPAM and Circuit data and have already noticed a few data errors that don't conform with our internal structures.

A regex input validation would be an excellent start. Still, taking this further, it would be great to allow administrators to write rules that can use basic logic combined with data within fields and custom fields relating to the current record.

An example for the circuit object, when adding decommissioned date I would want not this before the installed date.

If Date_installed > Date_Decommissioned_Custom,
Then true,
Else false

@tomehb commented on GitHub (Mar 12, 2020): I strongly agree with this; we are just started populating a Netbox instance with our DC, IPAM and Circuit data and have already noticed a few data errors that don't conform with our internal structures. A regex input validation would be an excellent start. Still, taking this further, it would be great to allow administrators to write rules that can use basic logic combined with data within fields and custom fields relating to the current record. An example for the circuit object, when adding decommissioned date I would want not this before the installed date. _If Date_installed > Date_Decommissioned_Custom, Then true, Else false_
Author
Owner

@jeremystretch commented on GitHub (May 8, 2020):

Bumping this from v2.9. More research and planning is needed regarding our overall strategy for custom fields moving forward.

@jeremystretch commented on GitHub (May 8, 2020): Bumping this from v2.9. More research and planning is needed regarding our overall strategy for custom fields moving forward.
Author
Owner

@jeremystretch commented on GitHub (Jul 24, 2020):

Blocked by #4878

@jeremystretch commented on GitHub (Jul 24, 2020): Blocked by #4878
Author
Owner

@jeremystretch commented on GitHub (Oct 15, 2020):

The implementation of this feature will be limited to providing regular expression support, and likely minimum/maximum values for integer custom fields.

@jeremystretch commented on GitHub (Oct 15, 2020): The implementation of this feature will be limited to providing regular expression support, and likely minimum/maximum values for integer custom fields.
Author
Owner

@geor-g commented on GitHub (Nov 4, 2020):

@jeremystretch Thanks for implementing this, and sorry for this noise in this old, closed issue.

Just a small question: Is it currently possible, to do input validation based on regexes on fields like 'Name'? If not, is something like this planned? Or should I rather open a new issue to discuss this?

@geor-g commented on GitHub (Nov 4, 2020): @jeremystretch Thanks for implementing this, and sorry for this noise in this old, closed issue. Just a small question: Is it currently possible, to do input validation based on regexes on fields like 'Name'? If not, is something like this planned? Or should I rather open a new issue to discuss this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#471