1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix merge conflict with async validators (#5606)

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-06-13 15:19:37 +03:00 committed by GitHub
parent 1393cc303d
commit 2eb585e88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<true>({
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`);
}
},
});