🎥 Make videos programmatically with React
import type {_InternalTypes} from 'remotion';
import {Internals} from 'remotion';
export const validateCompositionName = (
compName: string,
compositions: _InternalTypes['AnyComposition'][],
): string | null => {
if (!Internals.isCompositionIdValid(compName)) {
return Internals.invalidCompositionErrorMessage;
}
if (compositions.find((c) => c.id === compName)) {
return `A composition with that name already exists.`;
}
return null;
};
export const validateCompositionDimension = (
dimension: 'Width' | 'Height',
value: number,
): string | null => {
if (Number.isNaN(Number(value))) {
return 'Invalid number.';
}
if (Number(value) === 0) {
return dimension + ' cannot be zero.';
}
return null;
};
export const validateCompositionDuration = (value: number): string | null => {
if (value % 1 !== 0) {
return `Duration must be an integer.`;
}
if (Number.isNaN(value)) {
return 'Invalid number.';
}
if (value === 0) {
return 'Duration cannot be zero.';
}
return null;
};