Skip to content

Custom validators, referencing custom fields and folders #8950

Answered by jeremystretch
AndMrzv asked this question in Q&A
Discussion options

You must be logged in to vote
  1. How do I reference a custom field in a custom validator?

I don't think it's possible using the bare rules approach, but you should be able to do this by creating a CustomValidator class. Custom fields can be accessed as instance.cf.foo. (Still, it's probably worth an FR to enable custom field access using bare rules.)

  1. Does custom validator has to be inside netbox main directory to be assigned at config revision section or is there a way to use the default path (/etc/netbox/validators, or any other folder)?

Custom validator classes can be defined anywhere within the Python path. They just need to be importable within configuration.py for assignment under the CUSTOM_VALIDATORS confi…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@AndMrzv
Comment options

@AndMrzv
Comment options

@tomehb
Comment options

@PeterKnotek
Comment options

@PeterKnotek
Comment options

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