Parameterized custom policy checks?
Is there a way to pass a parameter to a SimpleCheck implementation module? Across most resources in my app, several checks need to be performed. Many of these checks are invariable, and can be put into a SimpleCheck module, but but one checks is variable, depending on a case-by-case basis. I would like to define one SimpleCheck module that does all these checks, and pass a parameter to it to handle that one variable case. Otherwise, I have to define repetitive checks in each of the resource modules. Is there a solution for this?
4 Replies
The my policies can look like right now is this:
But I'd like to do something like this:
I don't want to repeat the check for the
:super
role and active member status. I only want one check that takes a parameter.{Check, opts}
Then you should get opts
as the third argument to match?/3
🙂Like this?
yep!