Skip to content

Commit

Permalink
added validation method
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Sep 21, 2023
1 parent ce1185c commit b6b129a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/validate_database_json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
- name: Validate JSON
run: |
FILENAME="./fts3-databases/${{ inputs.FILENAME || github.event.inputs.FILENAME }}"
SCHEMA="./fts3-databases/databases/database_schema.json"
SCHEMA="./fts3-databases/database_schema.json"
if npx ajv validate --spec=draft2020 -s "$SCHEMA" -d "$FILENAME"; then
if npx ajv validate --spec=draft2020 --errors=text -s "$SCHEMA" -d "$FILENAME"; then
echo "JSON is valid."
else
echo "JSON is invalid."
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/validate_databases_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Validate JSON

on:
workflow_call:

workflow_dispatch:

jobs:
validate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: fts3-databases

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Use the Node.js version you prefer

- name: Install dependencies
run: npm install ajv-cli

- name: Validate JSON
run: |
FILENAME="./fts3-databases/*.json"
SCHEMA="./fts3-databases/database_schema.json"
if npx ajv validate --spec=draft2020 --errors=text -s "$SCHEMA" -d "$FILENAME"; then
echo "JSON is valid."
else
echo "JSON is invalid."
exit 1
fi
File renamed without changes.

0 comments on commit b6b129a

Please sign in to comment.