ADD: Basic JSON Schema test

This commit is contained in:
Robert Kossessa
2024-01-23 01:17:58 +01:00
parent e2222d51a6
commit 38ed926d69
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<script setup>
import schema from '@/data/profileSchema.json'
import axios from 'axios'
import { inject, ref } from 'vue'
const ajv = inject('ajv')
const message = ref('Waiting...')
try {
const res = await axios.get('http://localhost:3001/profiles/5867')
const profiles = res.data
console.log(profiles)
const validate = ajv.compile(schema)
const valid = validate(profiles)
if (!valid) {
message.value = 'Invalid!'
console.log(validate.errors)
} else {
message.value = 'Valid!'
console.log('valid!!!!!!!!!!!!!!!1111elf')
}
} catch (e) {
console.error(e)
}
</script>
<template>
{{ message }}
</template>
<style scoped>
</style>

View File

@@ -13,12 +13,17 @@ import {
} from '@/components/ui/command'
import { Input } from '@/components/ui/input'
import PixelBarTest from '@/components/device-gui/PixelBarTest.vue'
import SchemaTest from '@/components/SchemaTest.vue'
</script>
<template>
<!-- Dumping ground for testing components -->
<PixelBarTest />
<SchemaTest />
<input
v-model="defaultName"
type="text"