Custom Validation does not work for DataSource #8882

Closed
opened 2025-12-29 20:42:28 +01:00 by adam · 1 comment
Owner

Originally created by @amyasnikov on GitHub (Nov 25, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.6.5

Python version

3.10

Steps to Reproduce

  1. Add this snippet to your configuration.py
from extras.validators import CustomValidator

class MyValidator(CustomValidator):
    def validate(self, instance):
        self.fail("This error won't appear")

CUSTOM_VALIDATORS = {"core.datasource": [MyValidator]}
  1. Make sure that when you create Data Source from UI there is no validation error

This happens due to lack of super().clean() here:
https://github.com/netbox-community/netbox/blob/develop/netbox/core/models/data.py#L124

And, I suppose, it also causes other unpleasant side-effects because other NetBoxFeatureSet members .clean() are also not called

Expected Behavior

Validation Error happens after creation of the new Data Source after MyValidator has been added to CUSTOM_VALIDATORS

Observed Behavior

MyValidator is ignored, no error appeared.

Originally created by @amyasnikov on GitHub (Nov 25, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.6.5 ### Python version 3.10 ### Steps to Reproduce 1. Add this snippet to your configuration.py ``` from extras.validators import CustomValidator class MyValidator(CustomValidator): def validate(self, instance): self.fail("This error won't appear") CUSTOM_VALIDATORS = {"core.datasource": [MyValidator]} ``` 2. Make sure that when you create Data Source from UI there is no validation error This happens due to lack of `super().clean()` here: https://github.com/netbox-community/netbox/blob/develop/netbox/core/models/data.py#L124 And, I suppose, it also causes other unpleasant side-effects because other NetBoxFeatureSet members `.clean()` are also not called ### Expected Behavior Validation Error happens after creation of the new Data Source after MyValidator has been added to CUSTOM_VALIDATORS ### Observed Behavior MyValidator is ignored, no error appeared.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:42:28 +01:00
adam closed this issue 2025-12-29 20:42:29 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 28, 2023):

@amyasnikov thanks for taking the time to track this down and report it!

@jeremystretch commented on GitHub (Nov 28, 2023): @amyasnikov thanks for taking the time to track this down and report it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8882