Skip to content
Discussion options

You must be logged in to vote

The following works for me on v3.3.8:

from extras.validators import CustomValidator

class MyValidator(CustomValidator):
    def validate(self, instance):
        self.fail(f"Name is {instance.name}")

CUSTOM_VALIDATORS = {
    'virtualization.vminterface': (
        MyValidator(),
    )
}

When saving the device I get the interface name in the validation error message.

A simple non-code validator also works:

CUSTOM_VALIDATORS = {
    "virtualization.vminterface": [
        {
            "name": {
                "min_length": 5,
                "max_length": 10
            }
        }
    ]
}

You need to post your code if anyone is to replicate it.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bluikko
Comment options

@kkthxbye-code
Comment options

@bluikko
Comment options

Answer selected by bluikko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants