Skip to content

Commit

Permalink
Ajv 8 and schema 2020-12
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Jan 29, 2025
1 parent 7ed44c3 commit 2edeac3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@vitejs/plugin-vue": "^5.2.1",
"@vue/tsconfig": "^0.7.0",
"@vueuse/core": "^12.5.0",
"ajv": "^8.17.1",
"axios": "^1.7.9",
"datatransfer-files-promise": "^2.0.0",
"es-toolkit": "^1.31.0",
Expand Down
1 change: 1 addition & 0 deletions src/assets/sparvconfig.schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://spraakbanken.gu.se/sparv/schema.json",
"properties": {
"classes": {
Expand Down
5 changes: 4 additions & 1 deletion src/schema-form/JsonSchemaForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type JsonSchemaFormProps<D extends object> = {

<script setup lang="ts" generic="D extends {}">
import { withTheme } from "@rjsf/core";
import validator from "@rjsf/validator-ajv8";
import { customizeValidator } from "@rjsf/validator-ajv8";
import Ajv2020 from "ajv/dist/2020";
import { applyPureReactInVue, setVeauryOptions } from "veaury";
import { createRoot } from "react-dom/client";
import {
Expand Down Expand Up @@ -46,6 +47,8 @@ type FormInvalidError = {
const { alert } = useMessenger();
const validator = customizeValidator({ AjvClass: Ajv2020 });
function onError(errors: FormInvalidError[]) {
errors.forEach((error) =>
alert(`${error.property.split(".").pop()} ${error.message}`, "error"),
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

ajv@^8.0.0, ajv@^8.12.0:
ajv@^8.0.0, ajv@^8.12.0, ajv@^8.17.1:
version "8.17.1"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.17.1.tgz#37d9a5c776af6bc92d7f4f9510eba4c0a60d11a6"
integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==
Expand Down

0 comments on commit 2edeac3

Please sign in to comment.