mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-22 07:46:15 -04:00
refactor(date-converter): improved ux and layout
This commit is contained in:
parent
5fa811a583
commit
fd9ab59172
7 changed files with 346 additions and 76 deletions
|
@ -25,7 +25,15 @@ export type ValidationAttrs = {
|
|||
validationStatus: string | undefined;
|
||||
};
|
||||
|
||||
export function useValidation<T>({ source, rules }: { source: Ref<T>; rules: UseValidationRule<T>[] }) {
|
||||
export function useValidation<T>({
|
||||
source,
|
||||
rules,
|
||||
watch: watchRefs = [],
|
||||
}: {
|
||||
source: Ref<T>;
|
||||
rules: UseValidationRule<T>[];
|
||||
watch?: Ref<unknown>[];
|
||||
}) {
|
||||
const state = reactive<{
|
||||
message: string;
|
||||
status: undefined | 'error';
|
||||
|
@ -42,7 +50,7 @@ export function useValidation<T>({ source, rules }: { source: Ref<T>; rules: Use
|
|||
});
|
||||
|
||||
watch(
|
||||
[source],
|
||||
[source, ...watchRefs],
|
||||
() => {
|
||||
state.message = '';
|
||||
state.status = undefined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue