Skip to content

Custom validators based on assigned tags #16198

Closed Answered by Mailstorm-ctrl
Mailstorm-ctrl asked this question in Q&A
Discussion options

You must be logged in to vote

And I figured it out through trial and error:

def validate(self, instance):
                if "CheckMK Monitored".upper() in [tag.name.upper() for tag in instance._m2m_values['tags']] and instance.primary_ip is None:
                        self.fail("CheckMK tag requires a primary IP on the device!", field='tags')

Not sure if it's the 100% correct way, but it 100% works

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mailstorm-ctrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant