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.
|
||||
*/
|
||||
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`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user