Interface: RbacDecorators<T>
Defined in: packages/nestjs/src/decorators.ts:102
The requirement decorators, with names checked against T (see createRbacDecorators). With the default T, any name is accepted. In both cases a call without names, or with options that are not the last argument, is a type error.
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends RbacTypeConfig | DefaultRbacTypes |
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
CanAll | <A>(...args) => <TFunction, Y>(target, propertyKey?, descriptor?) => void | spatie v8.5 canAll(): requires EVERY listed entry. A 'a|b' entry still means "a or b". - @CanAll('edit articles', 'publish articles'), @CanAll(['edit articles', 'publish|review']) | packages/nestjs/src/decorators.ts:147 |
CanAny | <A>(...args) => <TFunction, Y>(target, propertyKey?, descriptor?) => void | spatie v8.5 canAny(): passes with ANY of the listed permissions. - @CanAny('edit articles', 'publish articles'), @CanAny(['edit articles', 'publish articles']) | packages/nestjs/src/decorators.ts:139 |
RequirePermissions | <A>(...args) => <TFunction, Y>(target, propertyKey?, descriptor?) => void | Requires permissions, like spatie's permission: middleware. Works on controllers and handlers. - @RequirePermissions('edit articles') - @RequirePermissions('edit articles|delete articles') — any of them - @RequirePermissions('edit articles', 'publish articles') — all of them - @RequirePermissions('a', 'b', { any: true }) — any of them - @RequirePermissions('edit articles', { guard: 'api' }) — in guard api (spatie's permission:edit articles,api) | packages/nestjs/src/decorators.ts:112 |
RequireRoleOrPermission | <A>(...args) => <TFunction, Y>(target, propertyKey?, descriptor?) => void | Passes when the subject has ANY of the names as a role OR as a permission, like spatie's role_or_permission: middleware. - @RequireRoleOrPermission('admin|edit articles') | packages/nestjs/src/decorators.ts:131 |
RequireRoles | <A>(...args) => <TFunction, Y>(target, propertyKey?, descriptor?) => void | Requires roles, like spatie's role: middleware. - @RequireRoles('admin'), @RequireRoles('admin|editor'), @RequireRoles('admin', 'editor') — any of them - @RequireRoles('admin', 'editor', { all: true }) — all of them - @RequireRoles('admin', { guard: 'api' }) — in guard api (spatie's role:admin,api) | packages/nestjs/src/decorators.ts:122 |
