* Validate input before executing operation
(
operation: () => Promise<T>,
validations: Array<{ condition: boolean; message: string }>,
options: {
errorMessage?: string;
showNotice?: boolean;
noticeHandler?: SafeAsyncNoticeHandler;
} = {}
)
| 124 | * Validate input before executing operation |
| 125 | */ |
| 126 | static async executeWithValidation<T>( |
| 127 | operation: () => Promise<T>, |
| 128 | validations: Array<{ condition: boolean; message: string }>, |
| 129 | options: { |
| 130 | errorMessage?: string; |
| 131 | showNotice?: boolean; |
| 132 | noticeHandler?: SafeAsyncNoticeHandler; |
| 133 | } = {} |
| 134 | ): Promise<T | undefined> { |
| 135 | const { showNotice = true, noticeHandler } = options; |
| 136 | |
| 137 | // Check all validations |
| 138 | for (const validation of validations) { |
| 139 | if (!validation.condition) { |
| 140 | if (showNotice) { |
| 141 | notifyIfRequested(validation.message, { |
| 142 | showNotice, |
| 143 | noticeHandler, |
| 144 | }); |
| 145 | } |
| 146 | return undefined; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // All validations passed, execute operation |
| 151 | return this.execute(operation, options); |
| 152 | } |
| 153 | } |
no test coverage detected