{"record":{"id":"c792536f08ace1bb","repo":"remotion-dev/remotion","slug":"direction-must-be-formatenum-wave-directions","errorCode":null,"errorMessage":"\"direction\" must be ${formatEnum(WAVE_DIRECTIONS)}, but got ${JSON.stringify(direction)}","messagePattern":"\"direction\" must be (.+?), but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/waves.ts","lineNumber":250,"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!WAVE_DIRECTIONS.includes(direction as WavesDirection)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`\"direction\" must be ${formatEnum(WAVE_DIRECTIONS)}, but got ${JSON.stringify(direction)}`,\n\t\t);\n\t}\n};\n\nconst validateWavesParams = (params: WavesParams): void => {\n\tassertEffectParamsObject(params, 'Waves');\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\tassertOptionalFiniteNumber(params.phase, 'phase');\n\tassertOptionalBoolean(params.maskToSourceAlpha, 'maskToSourceAlpha');\n","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/waves.ts#L232-L268","documentation":"Thrown by validateDirection() during waves() effect param validation. The waves effect accepts only 'horizontal' or 'vertical' as the direction value. This TypeError fires when direction is a string that is neither of those, or when it is a non-string type. The error message lists the allowed values via formatEnum(WAVE_DIRECTIONS).","triggerScenarios":"Called from validateWavesParams() at packages/effects/src/waves.ts:259 via validateDirection(params.direction). Fires when you pass waves({direction: 'left'}), waves({direction: 'h'}), waves({direction: 0}), or any other value besides 'horizontal' or 'vertical'. Omitting direction is valid (defaults to 'horizontal').","commonSituations":"Typo in the direction string (e.g., 'horizonal', 'Horizontal' with uppercase); using a numeric code (0/1) instead of the string enum; copying a direction value from a different effect that uses different enum values; case sensitivity surprise.","solutions":["Use exactly 'horizontal' or 'vertical' (lowercase, no typos).","Use the WavesDirection type to get compile-time checking: import type {WavesDirection} from '@remotion/effects'.","If direction comes from user input or data, validate/sanitize it before passing: const dir = ['horizontal','vertical'].includes(input) ? input : undefined."],"exampleFix":"// before\nimport {waves} from '@remotion/effects';\nwaves({direction: 'h'})         // throws\nwaves({direction: 'Horizontal'}) // throws — case-sensitive\nwaves({direction: 0})           // throws — not a string\n\n// after\nwaves({direction: 'horizontal'})  // valid\nwaves({direction: 'vertical'})    // valid\n\n// with type safety\nimport type {WavesDirection} from '@remotion/effects';\nconst dir: WavesDirection = 'horizontal';\nwaves({direction: dir})","handlingStrategy":"type-guard","validationCode":"import type {WavesDirection} from '@remotion/effects';\n\nconst VALID_DIRECTIONS: readonly WavesDirection[] = ['horizontal', 'vertical'];\n\nconst safeDirection = (d: unknown): WavesDirection | undefined =>\n  typeof d === 'string' && (VALID_DIRECTIONS as readonly string[]).includes(d)\n    ? (d as WavesDirection)\n    : undefined;\n\nwaves({direction: safeDirection(userInput)}); // falls back to default if invalid","typeGuard":"import type {WavesDirection} from '@remotion/effects';\n\nconst isWavesDirection = (v: unknown): v is WavesDirection =>\n  v === 'horizontal' || v === 'vertical';","tryCatchPattern":null,"preventionTips":["Use exactly the lowercase strings 'horizontal' or 'vertical'.","Import the WavesDirection type for compile-time safety.","Sanitize user/data-driven direction values before passing them."],"tags":["validation","waves-effect","typescript","params","enum","typeerror"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}