Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Validations support on M2M #6373

Open
1 of 12 tasks
michalis1 opened this issue Oct 16, 2024 · 1 comment
Open
1 of 12 tasks

Custom Validations support on M2M #6373

michalis1 opened this issue Oct 16, 2024 · 1 comment
Labels
type: feature Introduction of substantial new functionality to the application

Comments

@michalis1
Copy link

As ...

P.D. - Nautobot App Developer

I want ...

Custom validators to be able to apply validation rules to many-to-many fields, such as prefix locations or tags.

So that ...

Custom Validators will support compliance for many-to-many fields, allowing app developers to define compliance rules for these fields.

I know this is done when...

When creating a custom validator, the self.context['object'] provides the user's selections from the form. However, for many-to-many fields like tags, instead of getting the user's current form choices, we are getting the existing data from the database. To resolve this, we need access to the many-to-many fields within self.context['object']. For example, when a user edits a prefix, self.context['object'].locations should reflect the user's current selection, not the existing locations associated with the prefix.

Optional - Feature groups this request pertains to.

  • Automation
  • Circuits
  • DCIM
  • IPAM
  • Misc (including Data Sources)
  • Organization
  • Apps (and other Extensibility)
  • Security (Secrets, etc)
  • Image Management
  • UI/UX
  • Documentation
  • Other (not directly a platform feature)

Database Changes

No additional models or fields are required.

External Dependencies

No additional external dependencies are required.

@michalis1 michalis1 added triage This issue is new and has not been reviewed. type: feature Introduction of substantial new functionality to the application labels Oct 16, 2024
@timizuoebideri1 timizuoebideri1 removed the triage This issue is new and has not been reviewed. label Oct 16, 2024
@glennmatthews
Copy link
Contributor

Because updating many-to-many fields is a separate database operation from saving the object itself, this is not as straightforward to design/implement as it might seem. I get the desire/need for this functionality though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of substantial new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants