n8n/packages/nodes-base/nodes/Transform/utils/utils.ts
Tomi Turtiainen eb355df6c2
refactor: Replace deprecated ApplicationError in remaining nodes-base nodes (no-changelog) (#32473)
Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
2026-06-17 18:19:46 +00:00

18 lines
481 B
TypeScript

import { UserError } from 'n8n-workflow';
export const prepareFieldsArray = (fields: string | string[], fieldName = 'Fields') => {
if (typeof fields === 'string') {
return fields
.split(',')
.map((entry) => entry.trim())
.filter((entry) => entry !== '');
}
if (Array.isArray(fields)) {
return fields;
}
throw new UserError(
`The \'${fieldName}\' parameter must be a string of fields separated by commas or an array of strings.`,
{ level: 'warning' },
);
};