Provide forbiddenBecause
message in Can
child render function
#972
Labels
forbiddenBecause
message in Can
child render function
#972
Is your feature request related to a problem? Please describe.
When using the
Can
component, it is often desirable to inform the user, visually, why they cannot perform a certain action. However, it is verbose and cumbersome to surface the.because("...")
messages that one may define on their abilities. When you useCan
you have to:Describe the solution you'd like
Can
's child render function will accept a third argument (forbiddenBecause
), which will be the same string as outputted byForbiddenError.from(ability).unlessCan(...condition)?.message
.string | undefined
.string
whenallowed
isfalse
, returning either the default error message or a defined rule message. It will beundefined
whenallowed
istrue
.Describe alternatives you've considered (optional)
getRelevantRulesFor
Additional context (optional)
None
The text was updated successfully, but these errors were encountered: