From 2eb585e88ec157cc845c46860ef8bd9bc1aa12f2 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Mon, 13 Jun 2022 15:19:37 +0300 Subject: [PATCH] Fix merge conflict with async validators (#5606) Signed-off-by: Janne Savolainen --- .../input/validators/is-path.injectable.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/renderer/components/input/validators/is-path.injectable.ts b/src/renderer/components/input/validators/is-path.injectable.ts index 3374a9a610..c9800cb628 100644 --- a/src/renderer/components/input/validators/is-path.injectable.ts +++ b/src/renderer/components/input/validators/is-path.injectable.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { AsyncInputValidationError, inputValidator } from "../input_validators"; +import { asyncInputValidator } from "../input_validators"; import pathExistsInjectable from "../../../../common/fs/path-exists.injectable"; const isPathInjectable = getInjectable({ @@ -12,17 +12,12 @@ const isPathInjectable = getInjectable({ instantiate: (di) => { const pathExists = di.inject(pathExistsInjectable); - return inputValidator({ + return asyncInputValidator({ debounce: 100, condition: ({ type }) => type === "text", - - validate: async (value) => { - try { - await pathExists(value); - } catch { - throw new AsyncInputValidationError( - `${value} is not a valid file path`, - ); + validate: async value => { + if (!await pathExists(value)) { + throw new Error(`"${value}" is not a valid file path`); } }, });