ADD: Basic JSON Schema test
This commit is contained in:
34
src/components/SchemaTest.vue
Normal file
34
src/components/SchemaTest.vue
Normal 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>
|
||||||
@@ -13,12 +13,17 @@ import {
|
|||||||
} from '@/components/ui/command'
|
} from '@/components/ui/command'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import PixelBarTest from '@/components/device-gui/PixelBarTest.vue'
|
import PixelBarTest from '@/components/device-gui/PixelBarTest.vue'
|
||||||
|
import SchemaTest from '@/components/SchemaTest.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
|
<!-- Dumping ground for testing components -->
|
||||||
|
|
||||||
<PixelBarTest />
|
<PixelBarTest />
|
||||||
|
|
||||||
|
<SchemaTest />
|
||||||
|
|
||||||
<input
|
<input
|
||||||
v-model="defaultName"
|
v-model="defaultName"
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
Reference in New Issue
Block a user