feat: add validateConfig to trigger (#6040)

* feat: add validateConfig to trigger

* refactor: validateConfig

* fix: validate config
This commit is contained in:
citlalinda 2025-01-16 10:16:27 +08:00 committed by GitHub
parent fbec7c2e1d
commit 63ffe1a99d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 49 additions and 0 deletions

View File

@ -232,4 +232,20 @@ export default class extends Trigger {
options,
);
}
validateConfig(values) {
if (!values.data) {
return {
data: 'Data property is required',
};
}
if (!values.userId) {
return {
userId: 'UserId property is required',
};
}
return null;
}
}

View File

@ -235,4 +235,14 @@ export default class CollectionTrigger extends Trigger {
transaction: this.workflow.useDataSourceTransaction(dataSourceName, transaction),
});
}
validateConfig(values) {
if (!values.data) {
return {
data: 'Data property is required',
};
}
return null;
}
}

View File

@ -68,4 +68,26 @@ export default class ScheduleTrigger extends Trigger {
// });
// return !existed.length;
// }
validateConfig(values) {
if (!values.mode) {
return {
mode: 'Mode property is required',
};
}
if (!values.startsOn) {
return {
startsOn: 'StartsOn property is required',
};
}
if (values.mode === SCHEDULE_MODE.DATE_FIELD && !values.collection) {
return {
collection: 'Collection property is required',
};
}
return null;
}
}

View File

@ -20,6 +20,7 @@ export abstract class Trigger {
return true;
}
duplicateConfig?(workflow: WorkflowModel, options: Transactionable): object | Promise<object>;
validateConfig?(values: any): null | void | { [key: string]: string };
sync?: boolean;
execute?(
workflow: WorkflowModel,