mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 17:26:15 -04:00
ui-lib(new-component): added text input component in the c-lib
This commit is contained in:
parent
401f13f7e3
commit
aad8d84e13
14 changed files with 428 additions and 21 deletions
|
@ -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';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue