From 60ad737f6ff8f12dfa2716ca6ef4b5f18cbb376c Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 25 Oct 2018 07:28:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=84=20Add=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/verifyAndStoreOptionValue.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/verifyAndStoreOptionValue.ts b/src/verifyAndStoreOptionValue.ts index b69f127..c341cf0 100644 --- a/src/verifyAndStoreOptionValue.ts +++ b/src/verifyAndStoreOptionValue.ts @@ -10,6 +10,10 @@ function execWithCustomError(func: (...args: any[]) => any, showError: (error: E } } +/** + * Verifies that the given value is a valid value for this option, and throws an error otherwise. + * Also updates state variables if the value is correct. + */ export default function verifyAndStoreOptionValue({ option, value, @@ -24,7 +28,7 @@ export default function verifyAndStoreOptionValue({ message: IOption['message'], outputArgs: IState['outputArgs'], requiredOptions: IState['requiredOptions'], -}) { +}): void { //Verify value for correctness const verifyValue = execWithCustomError(verify.bind(null, value), (error) => `Invalid value set for option "${option}", the validation of "${value}" failed: ${String(error)}`); if (verifyValue !== true) {