The upgrade to Netbox 3.2 brings Custom Model Validation:
https://docs.netbox.dev/en/stable/customization/custom-validation/
or
https://netbox-next.wikimedia.org/admin/extras/configrevision/add/
As it was only supported on custom fields until now.
We should leverage this new feature to prevent entry mistakes.
Next step is to list all the fields that require custom validation and their expected patterns.
Wishlist from T310590#8083821 plus extra:
[x] site.slug: lower case, maybe also 5 chars?
[x] device.name: valid hostname (not FQDN, so no dots) regex,
[] device.name: if a 4 digit number is present the first digit must match the DC's digit prefix rule (eqiad => 1, etc.) - https://gerrit.wikimedia.org/r/c/operations/software/netbox-extras/+/917876
[x] device.asset_tag: custom WMF asset tag regex, to be removed from reports
[] ~~virtual_chassis.domain: FQDN regex (unless already validated by netbox)~~ - we're not going to add new VCs so that's not worth the effort.
[] port/interfaces names:
** console_port.name: unclear from the data, most have console0, some console-re[0-1], Ripe atlas devices have different values
** console_server_port.name: port[1-9][0-9]?
** power_port.name: PSU[1-2] (the current report checks for PSU\d|PEM \d|Power Supply \d, we still need all of them?)
** power_outlet.name: a positive integer - https://gerrit.wikimedia.org/r/c/operations/software/netbox-extras/+/917876
** interface.name: see the INTERFACES_REGEXP in the current report
[x] cables not specific enough
** test_duplicate_cable_label
** test_blank_cable_label
[x] Coherence
** test_purchase_date
** test_duplicate_serials
** test_serials
** test_ticket
** test_no_staged_servers
[x] Rack
** test_offline_rack
** test_online_rack
** test_rack_noposition