mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
feat: add validateConfig to trigger (#6040)
* feat: add validateConfig to trigger * refactor: validateConfig * fix: validate config
This commit is contained in:
parent
fbec7c2e1d
commit
63ffe1a99d
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user