Skip to content

Commit

Permalink
add support for draft version 2019 and 2020 and setting AJV's strict …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
thomasmost committed Jun 7, 2024
1 parent 0e8ed39 commit 7c0ecbb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ inputs:
target-dir:
description: "the directory (or directories, comma separated) containing the json files to validate"
required: true
all-errors:
description: "enable allErrors on AJV validator"
required: false
default: "false"
ajv-strict:
description: "enable AJV's strict mode, which does not adhere to the JSON Schema spec"
required: false
default: "false"
draft-version:
description: The draft version to use; supports 2019 or 2020
required: false
default: "2020"

runs:
using: "node20"
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gha-valjean",
"version": "0.1.1",
"version": "0.2.0",
"description": "",
"main": "index.js",
"packageManager": "pnpm@9.1.4",
Expand Down
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as core from "@actions/core";

import * as fs from "fs";
import Ajv from "ajv"
const ajv = new Ajv({allErrors: true})
import Ajv2019 from "ajv"
import Ajv2020 from 'ajv/dist/2020'



/**
Expand All @@ -14,6 +15,11 @@ export async function run(): Promise<void> {
// Fetch the value of the input 'who-to-greet' specified in action.yml
const schemaUrl = core.getInput("schema-url");
const targetDir = core.getInput("target-dir");
const allErrors = core.getInput("all-errors") === "true";
const strict = core.getInput("ajv-strict") === "true";
const draftVersion = core.getInput("draft-version");

const ajv = draftVersion === "2020" ? new Ajv2020({allErrors, strict}) : new Ajv2019({allErrors, strict});

const targetDirs = targetDir.split(",");

Expand Down

0 comments on commit 7c0ecbb

Please sign in to comment.