diff options
author | 2023-05-07 23:31:10 +0200 | |
---|---|---|
committer | 2023-05-14 22:30:23 +0200 | |
commit | aad8d84e13ce31c1b7c1cbb930fb8bd4c0abe13a (patch) | |
tree | c483e3a25c858c09c73496616d95f168d8b9298d /src/composable/validation.ts | |
parent | 401f13f7e305d60097db2334642e423c41d8897d (diff) | |
download | it-tools-aad8d84e13ce31c1b7c1cbb930fb8bd4c0abe13a.tar.gz it-tools-aad8d84e13ce31c1b7c1cbb930fb8bd4c0abe13a.tar.zst it-tools-aad8d84e13ce31c1b7c1cbb930fb8bd4c0abe13a.zip |
ui-lib(new-component): added text input component in the c-lib
Diffstat (limited to 'src/composable/validation.ts')
-rw-r--r-- | src/composable/validation.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/composable/validation.ts b/src/composable/validation.ts index 4858110..e7fc70c 100644 --- a/src/composable/validation.ts +++ b/src/composable/validation.ts @@ -1,3 +1,4 @@ +import { get, type MaybeRef } from '@vueuse/core'; import _ from 'lodash'; import { reactive, watch, type Ref } from 'vue'; @@ -31,7 +32,7 @@ export function useValidation<T>({ watch: watchRefs = [], }: { source: Ref<T>; - rules: UseValidationRule<T>[]; + rules: MaybeRef<UseValidationRule<T>[]>; watch?: Ref<unknown>[]; }) { const state = reactive<{ @@ -55,7 +56,7 @@ export function useValidation<T>({ state.message = ''; state.status = undefined; - for (const rule of rules) { + for (const rule of get(rules)) { if (isFalsyOrHasThrown(() => rule.validator(source.value))) { state.message = rule.message; state.status = 'error'; |