From f7fc779e6334af129e323ae6ec22d97059eb0363 Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Mon, 15 May 2023 00:41:45 +0200 Subject: refactor(ui): replaced some n-input with c-input-text --- src/tools/json-diff/json-diff.vue | 67 ++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 40 deletions(-) (limited to 'src/tools/json-diff/json-diff.vue') diff --git a/src/tools/json-diff/json-diff.vue b/src/tools/json-diff/json-diff.vue index 0db06cc..811f7fa 100644 --- a/src/tools/json-diff/json-diff.vue +++ b/src/tools/json-diff/json-diff.vue @@ -1,30 +1,25 @@ @@ -33,7 +28,6 @@ import JSON5 from 'json5'; import { withDefaultOnError } from '@/utils/defaults'; -import { useValidation } from '@/composable/validation'; import { isNotThrowing } from '@/utils/boolean'; import DiffsViewer from './diff-viewer/diff-viewer.vue'; @@ -43,17 +37,10 @@ const rawRightJson = ref(''); const leftJson = computed(() => withDefaultOnError(() => JSON5.parse(rawLeftJson.value), undefined)); const rightJson = computed(() => withDefaultOnError(() => JSON5.parse(rawRightJson.value), undefined)); -const createJsonValidation = (json: Ref) => - useValidation({ - source: json, - rules: [ - { - validator: (value) => value === '' || isNotThrowing(() => JSON5.parse(value)), - message: 'Invalid JSON', - }, - ], - }); - -const leftJsonValidation = createJsonValidation(rawLeftJson); -const rightJsonValidation = createJsonValidation(rawRightJson); +const jsonValidationRules = [ + { + validator: (value: string) => value === '' || isNotThrowing(() => JSON5.parse(value)), + message: 'Invalid JSON format', + }, +]; -- cgit v1.2.3