feat: add ScopeObjectMatch trait for easy scope validation#11132
Merged
feat: add ScopeObjectMatch trait for easy scope validation#11132
ScopeObjectMatch trait for easy scope validation#11132Conversation
Contributor
Package Changes Through 6729c30There are 10 changes which include @tauri-apps/api with prerelease, tauri-bundler with prerelease, tauri-cli with prerelease, tauri with prerelease, tauri-runtime-wry with prerelease, tauri-runtime with prerelease, tauri-utils with prerelease, @tauri-apps/cli with prerelease, tauri-build with prerelease, tauri-codegen with prerelease Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
amrbashir
reviewed
Sep 25, 2024
amrbashir
approved these changes
Sep 25, 2024
ScopeObjectMatch for easy scope validationScopeObjectMatch trait for easy scope validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a DX improvement for developers that are adding scopes to their commands (likely in plugins).
If the validation of a scope can be represented as a
bool, the type can implementScopeObjectMatchto enable a helper method onCommandScopethat automatically checks that all deny scopes are not matched and enforcing allow scopes if they exist.turns code like:
into
which removes the chances for developers to make simple logic errors when validating the deny and allow scopes - especially if they are using it multiple times in many commands.