diff --git a/src/composable/validation.ts b/src/composable/validation.ts index 472ca4b2..bae798c0 100644 --- a/src/composable/validation.ts +++ b/src/composable/validation.ts @@ -6,7 +6,7 @@ type ValidatorReturnType = unknown; export interface UseValidationRule { validator: (value: T) => ValidatorReturnType - message: string + message: any } export function isFalsyOrHasThrown(cb: () => ValidatorReturnType): boolean { @@ -56,7 +56,6 @@ export function useValidation({ watch( [source, ...watchRefs], () => { - state.message = ''; state.status = undefined; for (const rule of get(rules)) { diff --git a/src/tools/json-to-yaml-converter/json-to-yaml.vue b/src/tools/json-to-yaml-converter/json-to-yaml.vue index cbaeb22d..f7dfe33b 100644 --- a/src/tools/json-to-yaml-converter/json-to-yaml.vue +++ b/src/tools/json-to-yaml-converter/json-to-yaml.vue @@ -5,21 +5,22 @@ import type { UseValidationRule } from '@/composable/validation'; import { isNotThrowing } from '@/utils/boolean'; import { withDefaultOnError } from '@/utils/defaults'; +const { t } = useI18n(); const transformer = (value: string) => withDefaultOnError(() => stringify(JSON5.parse(value)), ''); const rules: UseValidationRule[] = [ { validator: (value: string) => value === '' || isNotThrowing(() => stringify(JSON5.parse(value))), - message: 'Provided JSON is not valid.', + message: computed(() => t('tools.json-to-yaml-converter.invalid')), }, ];