mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Wait Node): Add validation for wait amount and unit (#18239)
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { validateWaitAmount, validateWaitUnit } from './validation';
|
||||
import { updateDisplayOptions } from '../../utils/utilities';
|
||||
import {
|
||||
formDescription,
|
||||
@@ -47,6 +48,7 @@ const toWaitAmount: INodeProperties = {
|
||||
},
|
||||
default: 1,
|
||||
description: 'The time to wait',
|
||||
validateType: 'number',
|
||||
};
|
||||
|
||||
const unitSelector: INodeProperties = {
|
||||
@@ -487,9 +489,24 @@ export class Wait extends Webhook {
|
||||
|
||||
let waitTill: Date;
|
||||
if (resume === 'timeInterval') {
|
||||
const unit = context.getNodeParameter('unit', 0) as string;
|
||||
const unit = context.getNodeParameter('unit', 0);
|
||||
|
||||
if (!validateWaitUnit(unit)) {
|
||||
throw new NodeOperationError(
|
||||
context.getNode(),
|
||||
"Invalid wait unit. Valid units are 'seconds', 'minutes', 'hours', or 'days'.",
|
||||
);
|
||||
}
|
||||
|
||||
let waitAmount = context.getNodeParameter('amount', 0);
|
||||
|
||||
if (!validateWaitAmount(waitAmount)) {
|
||||
throw new NodeOperationError(
|
||||
context.getNode(),
|
||||
'Invalid wait amount. It must be a positive number.',
|
||||
);
|
||||
}
|
||||
|
||||
let waitAmount = context.getNodeParameter('amount', 0) as number;
|
||||
if (unit === 'minutes') {
|
||||
waitAmount *= 60;
|
||||
}
|
||||
@@ -514,7 +531,7 @@ export class Wait extends Webhook {
|
||||
} catch (e) {
|
||||
throw new NodeOperationError(
|
||||
context.getNode(),
|
||||
'[Wait node] Cannot put execution to wait because `dateTime` parameter is not a valid date. Please pick a specific date and time to wait until.',
|
||||
'Cannot put execution to wait because `dateTime` parameter is not a valid date. Please pick a specific date and time to wait until.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user