Skip to content

Custom Validation does not work for DataSource #14349

@amyasnikov

Description

@amyasnikov

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.

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions