-
Notifications
You must be signed in to change notification settings - Fork 44
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
How to perform logical operations? #112
Comments
I believe that currently no way to do that: you'd have to push that logic down into the params that you pass to the store. But in my opinion it would be a useful feature. Do you have any suggestions for an API to achieve this? |
Currently here's how i plan to do it in our organization
I have created a wrapper that checks if the node you have requested has an _and. This has way too much limitation hence we do not plan to use it actively. |
I wonder if one way to speak to this would be to allow the user to provide a function with their logic within the schema. The function would be passed the params and env, and its result would be injected into the store when new Confidence.Store({
isAllowedAccess: {
$fn: ({ location, device }, { NODE_ENV }) => NODE_ENV === 'production' && location !== 'US' && device !== 'iphone'
}
}); |
I like that suggestion @devinivy. This would serve a broad range of use cases without complexifying the API a bunch. If we were to go the logical operators route we'd have to add numerous operators and there will always be people who'd want specific operator but here you can do whatever you want in your function. |
Whats the status of this? Looking to regex against ENVs for manifest plugins. This |
If there are no other proposals, I would take a PR for |
Suppose a value of a key depends on multiple factors. Say a variable isAllowedAcess depends on the user's location and the user's device. Is there a way to design such schema?
The text was updated successfully, but these errors were encountered: