ui-lib(new-component): added text input component in the c-lib
This commit is contained in:
1 parent
401f13f7e3
commit
aad8d84e13
14 files changed
+428
-21
No files matched your search
@@ -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';
|
||||
|
||||
Reference in new issue
Block a user