{"record":{"id":"bd354119e0340868","repo":"remotion-dev/remotion","slug":"input-input-is-not-a-valid-transform-must-be-a","errorCode":null,"errorMessage":"input ${input} is not a valid transform. Must be a number or a string ending in one of the following units: ${lengthUnits.join(', ')}","messagePattern":"input (.+?) is not a valid transform\\. Must be a number or a string ending in one of the following units: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/animation-utils/src/transformation-helpers/make-transform/is-unit-with-string.ts","lineNumber":18,"sourceCode":"import {lengthUnits} from '../../type';\n\nexport const isUnitWithString = (input: unknown, units: readonly string[]) => {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tif (!units.find((u) => input.endsWith(u))) {\n\t\tthrow new Error(\n\t\t\t`input ${input} does not end with a valid unit. Valid units are: ${units.join(\n\t\t\t\t', ',\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tconst match = input.match(/([0-9.]+)([a-z%]+)/);\n\tif (!match) {\n\t\tthrow new Error(\n\t\t\t`input ${input} is not a valid transform. Must be a number or a string ending in one of the following units: ${lengthUnits.join(\n\t\t\t\t', ',\n\t\t\t)}`,\n\t\t);\n\t}\n\n\treturn true;\n};\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/animation-utils/src/transformation-helpers/make-transform/is-unit-with-string.ts#L1-L27","documentation":"Thrown by isUnitWithString when the string ends with a valid unit but does not match the number+unit regex /([0-9.]+)([a-z%]+)/. The suffix is recognized but the numeric prefix is missing or malformed, so the value cannot be used as a transform dimension.","triggerScenarios":"Passing a keyword like 'auto' or 'none' that happens to end in a unit-like suffix; a unit-only value with no leading number like 'px' or 'deg'; a malformed string like 'apx' where the prefix is non-numeric.","commonSituations":"Passing CSS keywords (auto/none) to a transform helper that only accepts measured lengths; malformed user input that happens to end in a unit; concatenation bugs that drop the number.","solutions":["Provide a numeric value before the unit ('px' -> '0px', 'auto' -> '0px').","Pass a plain number if you want the default unit applied automatically.","Validate user-supplied transform strings with the regex /^([0-9.]+)([a-z%]+)$/ before passing them to a transform helper."],"exampleFix":"// before\ntranslate('auto');   // keyword, no leading number\ntranslate('px');     // unit only, no number\n\n// after\ntranslate('0px');\n// or\ntranslate(0);","handlingStrategy":"type-guard","validationCode":"const NUM_PLUS_UNIT = /^([0-9.]+)([a-z%]+)$/i;\nconst isNumberUnitString = (s: string): boolean => NUM_PLUS_UNIT.test(s);\n// usage: isNumberUnitString('100px') === true; isNumberUnitString('auto') === false","typeGuard":"const NUMBER_UNIT_RE = /^([0-9.]+)([a-z%]+)$/i;\nconst isMeasuredString = (v: unknown): v is string =>\n  typeof v === 'string' && NUMBER_UNIT_RE.test(v);","tryCatchPattern":null,"preventionTips":["Never pass CSS keywords (auto, none) to transform helpers — they require a measured length.","Validate user-supplied transform strings with /^([0-9.]+)([a-z%]+)$/ before passing.","Pass a plain number when you want the default unit applied automatically."],"tags":["transform","units","validation","css"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}