{"record":{"id":"d88934dc635fd2e1","repo":"remotion-dev/remotion","slug":"direction-must-be-formatenum-zigzag-directions","errorCode":null,"errorMessage":"\"direction\" must be ${formatEnum(ZIGZAG_DIRECTIONS)}, but got ${JSON.stringify(direction)}","messagePattern":"\"direction\" must be (.+?), but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/zigzag.ts","lineNumber":235,"sourceCode":"\t\t\t`\"colors\" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`,\n\t\t);\n\t}\n\n\tfor (let i = 0; i < colors.length; i++) {\n\t\tassertRequiredColor(colors[i], `colors[${i}]`);\n\t}\n};\n\nconst validateDirection = (direction: unknown): void => {\n\tif (direction === undefined) {\n\t\treturn;\n\t}\n\n\tif (\n\t\ttypeof direction !== 'string' ||\n\t\t!ZIGZAG_DIRECTIONS.includes(direction as ZigzagDirection)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`\"direction\" must be ${formatEnum(ZIGZAG_DIRECTIONS)}, but got ${JSON.stringify(direction)}`,\n\t\t);\n\t}\n};\n\nconst validateZigzagParams = (params: ZigzagParams): void => {\n\tassertEffectParamsObject(params, 'Zigzag');\n\tvalidateColors(params.colors);\n\tvalidateDirection(params.direction);\n\tassertOptionalFiniteNumber(params.thickness, 'thickness');\n\tassertOptionalFiniteNumber(params.gap, 'gap');\n\tassertOptionalFiniteNumber(params.angle, 'angle');\n\tassertOptionalFiniteNumber(params.offset, 'offset');\n\tassertOptionalFiniteNumber(params.amplitude, 'amplitude');\n\tassertOptionalFiniteNumber(params.wavelength, 'wavelength');\n\tassertOptionalBoolean(params.maskToSourceAlpha, 'maskToSourceAlpha');\n\n\tconst thickness = params.thickness ?? DEFAULT_THICKNESS;","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/zigzag.ts#L217-L253","documentation":"Zigzag's direction must be one of the ZIGZAG_DIRECTIONS enum ('horizontal' or 'vertical'); validateDirection throws a TypeError for anything else (undefined is allowed and defaults to 'horizontal'). The check uses Array.includes on the const tuple, so typos, wrong case, or non-string values are rejected.","triggerScenarios":"Calling zigzag({direction: 'h'}), zigzag({direction: 'Horizontal'}), zigzag({direction: 'diagonal'}), zigzag({direction: 0}), or zigzag({direction: null}).","commonSituations":"Abbreviating the value; using wrong casing; copying a value from a different effect's enum; passing a numeric index expecting it to map.","solutions":["Use exactly 'horizontal' or 'vertical' (lowercase).","Omit direction to get the 'horizontal' default.","If the value comes from user/config input, constrain it with a union type or validate against ['horizontal','vertical'] first."],"exampleFix":"// before\nzigzag({direction: 'h'});\nzigzag({direction: 'Vertical'});\n\n// after\nzigzag({direction: 'horizontal'});\nzigzag({direction: 'vertical'});","handlingStrategy":"type-guard","validationCode":"import {zigzag} from '@remotion/effects';\n\nconst ZIGZAG_DIRECTIONS = ['horizontal', 'vertical'] as const;\ntype Dir = (typeof ZIGZAG_DIRECTIONS)[number];\n\nconst dir: unknown = config.direction;\nconst safeDir = (typeof dir === 'string' && (ZIGZAG_DIRECTIONS as readonly string[]).includes(dir))\n  ? (dir as Dir)\n  : undefined; // let default 'horizontal' apply\n\nzigzag({direction: safeDir});","typeGuard":"const ZIGZAG_DIRECTIONS = ['horizontal', 'vertical'] as const;\ntype ZigzagDirection = (typeof ZIGZAG_DIRECTIONS)[number];\n\nconst isZigzagDirection = (v: unknown): v is ZigzagDirection =>\n  typeof v === 'string' && (ZIGZAG_DIRECTIONS as readonly string[]).includes(v);\n\n// usage:\nzigzag({direction: isZigzagDirection(dir) ? dir : undefined});","tryCatchPattern":"try {\n  return <VideoEffects effects={[zigzag({direction})]} />;\n} catch (err) {\n  if (err instanceof TypeError && /\"direction\" must be/.test(err.message)) {\n    return <VideoEffects effects={[zigzag({direction: 'horizontal'})]} />;\n  }\n  throw err;\n}","preventionTips":["Use only the literal strings 'horizontal' or 'vertical' (lowercase).","Omit direction to get the 'horizontal' default rather than guessing a value.","Constrain config-driven input with a union type or the isZigzagDirection guard."],"tags":["validation","typescript","api-misuse","enum"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}