Skip to content

[Feature]: Add a contains operator for membership #45

@mitcheaton1

Description

@mitcheaton1

Problem description

It would be nice to add some more membership operators.

For example, I have auth_roles on a viewer, which is a list of roles (viewer has_many auth_roles). I want to check that :start_discussions role is a member of the viewers auth roles.

permit()
|> permission_to(:start_discussion, Article, viewer: [auth_roles: {:contains, [:start_discussions]}])

Proposed solution

Add an operator like contains to check inside of a list

Alternatives considered

No response

Use case

To use when you are checking an association that is a list for membership

Desired API/code example

permit()
|> permission_to(:start_discussion, Article, viewer: [auth_roles: {:contains, [:start_discussions]}])

Priority (1-5)

1 - Low - Nice to have

Additional Context

No response

Checklist

  • I have searched for existing issues before creating this one
  • I have checked the roadmap in the README
  • This is a feature request, not a bug report or question. For general questions, please use Elixir Slack's Permit channel.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions