Fix merge conflict with async validators (#5606)

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and GitHub committed 2022-06-13 15:19:37 +03:00
1 parent 1393cc303d
commit 2eb585e88e
1 file changed
+5 -10
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; 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"; import pathExistsInjectable from "../../../../common/fs/path-exists.injectable";
const isPathInjectable = getInjectable({ const isPathInjectable = getInjectable({
@@ -12,17 +12,12 @@ const isPathInjectable = getInjectable({
instantiate: (di) => { instantiate: (di) => {
const pathExists = di.inject(pathExistsInjectable); const pathExists = di.inject(pathExistsInjectable);
return inputValidator<true>({ return asyncInputValidator({
debounce: 100, debounce: 100,
condition: ({ type }) => type === "text", condition: ({ type }) => type === "text",
validate: async value => {
validate: async (value) => { if (!await pathExists(value)) {
try { throw new Error(`"${value}" is not a valid file path`);
await pathExists(value);
} catch {
throw new AsyncInputValidationError(
`${value} is not a valid file path`,
);
} }
}, },
}); });