diff options
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'; |