MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / executeWithValidation

Method executeWithValidation

src/utils/safeAsync.ts:126–152  ·  view source on GitHub ↗

* Validate input before executing operation

(
		operation: () => Promise<T>,
		validations: Array<{ condition: boolean; message: string }>,
		options: {
			errorMessage?: string;
			showNotice?: boolean;
			noticeHandler?: SafeAsyncNoticeHandler;
		} = {}
	)

Source from the content-addressed store, hash-verified

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}

Callers 1

handleCreateMethod · 0.80

Calls 2

executeMethod · 0.95
notifyIfRequestedFunction · 0.85

Tested by

no test coverage detected