All files / libs/amalia-lang/formula/evaluate/shared/src/functions/misc/not index.ts

100% Statements 38/38
100% Branches 1/1
100% Functions 1/1
100% Lines 38/38

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 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { AmaliaFunctionCategory, AmaliaFunctionKeys, type AmaliaFormula } from '@amalia/amalia-lang/formula/types';
import { type ComputeEngineResult } from '@amalia/payout-calculation/types';
 
import { AmaliaFunctionDefault } from '../../AmaliaFunction';
 
export const miscNot = new AmaliaFunctionDefault<[ComputeEngineResult], boolean>({
  name: AmaliaFunctionKeys.NOT,
  category: AmaliaFunctionCategory.MISC,
 
  exec: (evaluate): boolean => !evaluate,
 
  nbParamsRequired: 1,
  description:
    'This function takes a boolean value as input and returns the logical negation of that value, effectively flipping true to false and false to true.',
 
  params: [{ name: 'parameter', description: 'Boolean value to revert.' }],
 
  examples: [
    {
      desc: 'Returns true if opportunity.name does not contains "Closed".',
      formula: 'NOT(CONTAINS(opportunity.name, "Closed")' as AmaliaFormula,
    },
    {
      desc: 'Returns false if the team name is equal to "BDR - FR".',
      formula: 'NOT(team.name = "BDR - FR")' as AmaliaFormula,
    },
    {
      desc: 'Returns false if 1 = 1',
      formula: 'NOT(1 = 1)' as AmaliaFormula,
      result: false,
    },
    {
      desc: 'Returns true when the parameter is null.',
      formula: 'NOT(null)' as AmaliaFormula,
      result: true,
    },
  ],
});