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 39 40 41 42 43 44 45 | 1x 1x 1x 1x 1x 67x 68x 68x 68x 68x 68x 68x 68x 68x 69x 2x 2x 2x 69x 69x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 68x 1x | import { AmaliaFunctionCategory, AmaliaFunctionKeys, type AmaliaFormula } from '@amalia/amalia-lang/formula/types';
import { assert } from '@amalia/ext/typescript';
import { AmaliaFunctionDefault } from '../../AmaliaFunction';
export const stringStartsWith = new AmaliaFunctionDefault<[string | null | undefined, string], boolean>({
name: AmaliaFunctionKeys.STARTS_WITH,
category: AmaliaFunctionCategory.STRING,
nbParamsRequired: 2,
description: 'Return true when the given Source String starts with the given Search String',
exec: (sourceString, searchString) => {
assert(
sourceString !== null && sourceString !== undefined,
`${AmaliaFunctionKeys.STARTS_WITH}: source string is null or undefined`,
);
return sourceString.toString().startsWith(searchString);
},
params: [
{ name: 'sourceString', description: 'String to look into: array, variables, fields, properties, string' },
{ name: 'searchString', description: 'String to look for: array, variables, fields, properties, string' },
],
examples: [
{
desc: 'Returns true if Opportunity type startsWith Renew.',
formula: 'STARTS_WITH(opportunity.type, "Renew")' as AmaliaFormula,
},
{
desc: 'Returns true.',
formula: 'STARTS_WITH("Jean Dupont", "J")' as AmaliaFormula,
result: true,
},
{
desc: 'Returns false since the check is case sensitive.',
formula: 'STARTS_WITH("Opportunity - Renewal XYZ", "opportunity")' as AmaliaFormula,
result: false,
},
],
});
|