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:
parent
1393cc303d
commit
2eb585e88e
@ -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`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user