mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
18 lines
472 B
TypeScript
18 lines
472 B
TypeScript
|
import { computed } from "@nuxtjs/composition-api";
|
||
|
|
||
|
export function useValidation(errorsRef) {
|
||
|
const errorMessages = computed(() =>
|
||
|
Object.values(errorsRef.value)
|
||
|
.filter(({ message, show }) => !!message && show)
|
||
|
.map(({ message }) => message)
|
||
|
);
|
||
|
|
||
|
const isValid = computed(() =>
|
||
|
Object.values(errorsRef.value).every(
|
||
|
({ message, messageOnly }) => message === null || messageOnly === true
|
||
|
)
|
||
|
);
|
||
|
|
||
|
return { errorMessages, isValid };
|
||
|
}
|