You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even if the following example works with “Validation Types” = “required”, I would like to know how to pass parameters / arguments.
The following example checks whether the vrf parameter is not empty for an ipam prefix.
However, I would like to transfer the value VRF via Configuration.py. So that I can also pass the value Tenent etc. Something like this: FieldNotEmpty(“vrf”)
Everything I have tried has not worked. So how can I pass a value to the function?
/opt/netbox/validators/custom.py
# Dynamischer Validator
class FieldNotEmpty(CustomValidator):
def validate(self, obj):
# Holt den Wert des angegebenen Feldes
field_value = getattr(obj, "vrf", None)
# Wenn das Feld leer ist, Fehler auslösen
if field_value is None:
self.fail(f"Custom Validator: Das Feld darf nicht leer sein.", field="vrf")
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Known document::
https://netboxlabs.com/docs/netbox/en/stable/customization/custom-validation/
https://youtu.be/DjwXaLXL3Z8?si=3LcIHNKmzd_EdibJ
Even if the following example works with “Validation Types” = “required”, I would like to know how to pass parameters / arguments.
The following example checks whether the vrf parameter is not empty for an ipam prefix.
However, I would like to transfer the value VRF via Configuration.py. So that I can also pass the value Tenent etc. Something like this: FieldNotEmpty(“vrf”)
Everything I have tried has not worked. So how can I pass a value to the function?
/opt/netbox/validators/custom.py
/opt/netbox/netbox/netbox/configuration.py
Beta Was this translation helpful? Give feedback.
All reactions