mirror of
https://github.com/n8n-io/n8n.git
synced 2026-12-04 08:42:01 +00:00
Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
18 lines
481 B
TypeScript
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' },
|
|
);
|
|
};
|