All files / lib/utils hasRestrictingConditions.ts

0% Statements 0/4
0% Branches 0/4
0% Functions 0/2
0% Lines 0/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9                 
import { Ability, AbilityTuple, MongoQueryOperators, Subject } from "@casl/ability";
import { Rule } from "@casl/ability/dist/types/Rule";
 
export default (ability: Ability, action: string, modelName: string): Rule<AbilityTuple<string, Subject>, Record<string | number | symbol, string | number | boolean | Record<string | number | symbol, unknown> | MongoQueryOperators>>[]|false => {
  const rules = ability.possibleRulesFor(action, modelName);
  const hasConditions = rules.length === 0 || rules.some(x => !!x.conditions);
  return (hasConditions) ? rules : false;
};