Code Monkey home page Code Monkey logo

v8r's Introduction

v8r

build coverage version license node

v8r is a command-line JSON and YAML validator that uses Schema Store to detect a suitable schema for your input files based on the filename.

Getting Started

One-off:

npx v8r@latest <filename>

Local install:

npm install -g v8r
v8r <filename>

Usage Examples

Validating files

v8r can validate JSON or YAML files. You can pass filenames or glob patterns:

# single filename
$ v8r package.json

# multiple files
$ v8r file1.json file2.json

# glob patterns
$ v8r 'dir/*.yml' 'dir/*.yaml'

DigitalOcean's Glob Tool can be used to help construct glob patterns

Manually specifying a schema

By default, v8r queries Schema Store to detect a suitable schema based on the filename.

# if v8r can't auto-detect a schema for your file..
$ v8r feature.geojson
✖ Could not find a schema to validate feature.geojson

# ..you can specify one using the --schema flag
$ v8r feature.geojson --schema https://json.schemastore.org/geojson
ℹ Validating feature.geojson against schema from https://json.schemastore.org/geojson ...
✔ feature.geojson is valid

Using a custom catlog

Using the --schema flag will validate all files matched by the glob pattern against that schema. You can also define a custom schema catalog. v8r will search any custom catalogs before falling back to Schema Store.

$ cat > my-catalog.json <<EOF
{ "\$schema": "https://json.schemastore.org/schema-catalog.json",
  "version": 1,
  "schemas": [ { "name": "geojson",
                 "description": "geojson",
                 "url": "https://json.schemastore.org/geojson.json",
                 "fileMatch": ["*.geojson"] } ] }
EOF

$ v8r feature.geojson -c my-catalog.json
ℹ Found schema in my-catalog.json ...
ℹ Validating feature.geojson against schema from https://json.schemastore.org/geojson ...
✔ feature.geojson is valid

This can be used to specify different custom schemas for multiple file patterns.

Configuration

v8r uses CosmiConfig to search for a configuration. This means you can specify your configuration in any of the following places:

  • package.json
  • .v8rrc
  • .v8rrc.json
  • .v8rrc.yaml
  • .v8rrc.yml
  • .v8rrc.js
  • .v8rrc.cjs
  • v8r.config.js
  • v8r.config.cjs

v8r only searches for a config file in the current working directory.

Example yaml config file:

# - One or more filenames or glob patterns describing local file or files to validate
# - overridden by passing one or more positional arguments
patterns: ['*json']

# - Level of verbose logging. 0 is standard, higher numbers are more verbose
# - overridden by passing --verbose / -v
# - default = 0
verbose: 2

# - Exit with code 0 even if an error was encountered. True means a non-zero exit
#   code is only issued if validation could be completed successfully and one or
#   more files were invalid
# - overridden by passing --ignore-errors
# - default = false
ignoreErrors: true

# - Remove cached HTTP responses older than cacheTtl seconds old.
#   Specifying 0 clears and disables cache completely
# - overridden by passing --cache-ttl
# - default = 600
cacheTtl: 86400

# - Output format for validation results
# - overridden by passing --format
# - default = text
format: "json"

# - A custom schema catalog.
#   This catalog will be searched ahead of any custom catalogs passed using
#   --catalogs or SchemaStore.org
#   The format of this is subtly different to the format of a catalog
#   passed via --catalogs (which matches the SchemaStore.org format)
customCatalog:
    schemas:
        - name: Custom Schema  # The name of the schema (required)
          description: Custom Schema  # A description of the schema (optional)

          # A Minimatch glob expression for matching up file names with a schema (required)
          fileMatch: ["*.geojson"]

          # A URL or local file path for the schema location (required)
          # Unlike the SchemaStore.org format, which has a `url` key,
          # custom catalogs defined in v8r config files have a `location` key
          # which can refer to either a URL or local file.
          # Relative paths are interpreted as relative to the config file location.
          location: foo/bar/geojson-schema.json

          # A custom parser to use for files matching fileMatch
          # instead of trying to infer the correct parser from the filename (optional)
          # This property is specific to custom catalogs defined in v8r config files
          parser: json5

The config file format is specified more formally in a JSON Schema:

Configuring a Proxy

It is possible to configure a proxy via global-agent using the GLOBAL_AGENT_HTTP_PROXY environment variable:

export GLOBAL_AGENT_HTTP_PROXY=http://myproxy:8888

Exit codes

  • v8r always exits with code 0 when:

    • The input glob pattern(s) matched one or more files, all input files were validated against a schema, and all input files were valid
    • v8r was called with --help or --version flags
  • By default v8r exits with code 1 when an error was encountered trying to validate one or more input files. For example:

    • No suitable schema could be found
    • An error was encountered during an HTTP request
    • An input file was not JSON or yaml
    • etc

    This behaviour can be modified using the --ignore-errors flag. When invoked with --ignore-errors v8r will exit with code 0 even if one of these errors was encountered while attempting validation. A non-zero exit code will only be issued if validation could be completed successfully and the file was invalid.

  • v8r always exits with code 97 when:

    • There was an error loading a config file
    • A config file was loaded but failed validation
  • v8r always exits with code 98 when:

    • An input glob pattern was invalid
    • An input glob pattern was valid but did not match any files
  • v8r always exits with code 99 when:

    • The input glob pattern matched one or more files, one or more input files were validated against a schema and the input file was invalid

Versioning

v8r follows semantic versioning. For this project, the "API" is defined as:

  • CLI flags and options
  • CLI exit codes
  • The configuration file format
  • The native JSON output format

A "breaking change" also includes:

  • Dropping compatibility with a major Node JS version
  • Dropping compatibility with a JSON Schema draft

FAQ

❓ How does v8r decide what schema to validate against if I don't supply one?

💡 v8r queries the Schema Store catalog to try and find a suitable schema based on the name of the input file.

❓ My file is valid, but it doesn't validate against one of the suggested schemas.

💡 v8r is a fairly thin layer of glue between Schema Store (where the schemas come from) and ajv (the validation engine). It is likely that this kind of problem is either an issue with the schema or validation engine.

❓ What JSON schema versions are compatible?

💡 v8r works with JSON schema drafts:

  • draft-04
  • draft-06
  • draft-07
  • draft 2019-09
  • draft 2020-12

❓ Will 100% of the schemas on schemastore.org work with this tool?

💡 No. There are some with known issues

❓ Can v8r validate against a local schema?

💡 Yes. The --schema flag can be either a path to a local file or a URL. You can also use a config file to include local schemas in a custom catalog.

v8r's People

Contributors

abrifq avatar chris48s avatar dependabot[bot] avatar jimmytournemaine avatar nvuillam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

v8r's Issues

Release a stable version and document definition of a breaking change

The big thing I want to get nailed down while I can still make consequence-free breaking changes is #149 - config file format

Once established, non backwards-compatible changes to the config file format should be part of the definition of a breaking change

Once I've worked the kinks out of a config file format, I think it makes sense to put out a 1.0 release.

Resolve relative schema refs

Some schemas like

Don't work because the $refs to other files in the same dir are not resolved.

Over in https://github.com/chris48s/json-schema-viewer I solved this by spidering and pre-fetching the schema and all relative schemas to a local directory before rendering. That solution probably doesn't play nice with v8r in its current form because the schemas are held in memory and flat-cache stores everything in one file.

I wonder if the right solution for v8r is a better loadSchema function?

fileMatch collision

I'm not sure what the right 🔧 is... but I have a GitHub Action called deploy.yaml that isn't validated against the GitHub Action schema because the Deployer Recipe takes precedence.

Some potential fixes:

  • #17 which would allow me to define my own catalog and exclude Deployer Recipe
  • new command line flag to ignore schema(s) (like Deployer Recipe)

Provide SARIF output

Aside from the exit code, all of v8r's output is optimised for reading by humans. It would be useful to also provide some kind of machine-readable output (e.g: via a --output json flag, or something)

In #21 @nvuillam suggested SARIF format:

what about SARIF output ? https://sarifweb.azurewebsites.net/

More and more analyzers use this common format, and to be honest it would help me to integrate v8r even better within MegaLinter :)

eslint has a SARIF formatter, already widely used :) ( 50k dl / week )

https://www.npmjs.com/package/@microsoft/eslint-formatter-sarif

Here is an example: there are some standard attributes (not sure any of them is required), and for anything not in the spec you can put it in properties

SARIF example
{
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Bandit",
          "rules": [
            {
              "id": "B110",
              "name": "try_except_pass",
              "helpUri": "https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html"
            }
          ]
        }
      },
      "invocations": [
        {
          "executionSuccessful": true,
          "endTimeUtc": "2021-12-05T00:20:06Z"
        }
      ],
      "results": [
        {
          "message": {
            "text": "Try, Except, Pass detected."
          },
          "level": "note",
          "locations": [
            {
              "physicalLocation": {
                "region": {
                  "snippet": {
                    "text": "except:\n"
                  },
                  "startLine": 3
                },
                "artifactLocation": {
                  "uri": "file:///github/workspace/python_bad_1.py"
                },
                "contextRegion": {
                  "snippet": {
                    "text": "    pass\nexcept:\n    pass\n"
                  },
                  "endLine": 4,
                  "startLine": 2
                }
              }
            }
          ],
          "properties": {
            "issue_confidence": "HIGH",
            "issue_severity": "LOW"
          },
          "ruleId": "B110",
          "ruleIndex": 0
        }
      ]
    }
  ],
  "version": "2.1.0",
  "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json"
}

Would this be a good fit for v8r?

Unable to load local file as $ref

I'm trying to modularize some schema definitions by splitting out common definitions into their own files but I'm having troube referencing them from the local file system. These are all local files, none from the json-schema site.

I feel like I'm missing something simple and after looking through the docs for ajv and v8r I'm still a bit lost!

Example:

Dir layout

schemas/components/price.json
schemas/ammo.json
src/packs/ammo/*.yaml

.v8rrc.yaml

customCatalog:
  schemas:
    - name: "Packs/Ammo"
      description: "Schema for validating Ammo YAML fragments"
      fileMatch: ["src/packs/ammo/*.yaml"]
      location: "schema/ammo.json"

schemas/ammo.json

Cut out quite a lot for brevity, hopefully still valid. It works with price as it's own inline definition ("$ref": "#/definitions/Price"), just not as a $ref to a file.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/CPRC-Ammo",
  "definitions": {
    "CPRC-Ammo": {
      "type": "object",
      "additionalProperties": false,
      "description": "Definition of an Ammo Compendium Item for FVTT system Cyberpunk RED - Core",
      "properties": {
        "system": {
          "description": "The system's values for the Ammo item",
          "$ref": "#/definitions/System"
        },
      "required": [
        "system"
      ],
      "title": "CPRC: Ammo Compendium Item"
    },
    "System": {
      "type": "object",
      "additionalProperties": false,
      "description": "CPRC Ammo Item definition",
      "properties": {
        "price": {
          "description": "Item Price,
          "$ref": "./components/price.json"
        },
      },
      "required": [
        "price"
      ],
      "title": "System"
    },
  }
}

schemas/components/price.json

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "market": {
      "type": "integer"
    }
  },
  "required": [
    "market"
  ],
  "title": "Price"
}

npx v8r src/packs/ammo/arrow.armor.piercing.yaml

ℹ Loaded config file from .v8rrc.yaml
ℹ Processing src/packs/ammo/arrow.armor.piercing.yaml
ℹ Found schema in .v8rrc.yaml ...
ℹ Validating src/packs/ammo/arrow.armor.piercing.yaml against schema from /home/ryan/git/fvtt-cyberpunk-red-core/schema/ammo.json ...
✖ Failed fetching components/price.json

{
  "results": {
    "src/packs/ammo/arrow.armor.piercing.yaml": {
      "fileLocation": "src/packs/ammo/arrow.armor.piercing.yaml",
      "schemaLocation": "/home/ryan/git/fvtt-cyberpunk-red-core/schema/ammo.json",
      "valid": null,
      "errors": [],
      "code": 1
    }
  }
}

Allow cache name to be set in config file

This is not super high priority as the only place I customise this is for running tests, but it would be nice if the cache name could be set in the config file as well as using an env var.

Cache is bypassed when v8r is invoked using npx (and not installed locally)

The default cache path for flat-cache is node_modules/flat-cache/.cache. That's fine if you npm install but if you don't have it installed locally

npx filename.json
npx filename.json

doesn't use the cache second time round because npx installs a clean copy of the package each time. This isn't a huge deal because if you care about speed, you won't want to install a new copy every time you run it (which takes longer than the validation itself). Equally this could be solved by setting cacheDir to somewhere outside node_modules.

Support jsonc and json5

Currently, running v8r on jsonc files like tsconfig.json fails with not being able to parse the json properly

Newer ajv version supports jsonc and json5, would love to see these supports land in v8r as well

Probably related to #123

Allow to append json schema default catalog + local catalog

I have a request on Mega-Linter about allowing to specify the schema to validate a file

It could be done using v8r option -c to use a local catalog, but it would make loose the capability to use default catalog for other files

Would it be possible to add an option --append-catalog, so instead of just using local catalog , it would use the result of the append of -c and schema store?

Thanks !

Native proxy support

Is there any way to let v8r use a proxy natively? I'm failing to run v8r in our corporate network:

root@e9c0fed03724:/app# export | grep proxy
declare -x http_proxy="http://192.168.5.2:8888"
declare -x https_proxy="http://192.168.5.2:8888"

root@e9c0fed03724:/app# v8r -v .gitlab-ci.yml 
ℹ No config file found
ℹ Merged args/config: {
  "_": [],
  "v": 1,
  "verbose": 1,
  "ignore-errors": false,
  "ignoreErrors": false,
  "cache-ttl": 600,
  "cacheTtl": 600,
  "format": "text",
  "$0": "v8r",
  "patterns": [
    ".gitlab-ci.yml"
  ]
}
ℹ Processing ./.gitlab-ci.yml
ℹ Cache miss: calling https://www.schemastore.org/api/json/catalog.json
✖ Failed fetching https://www.schemastore.org/api/json/catalog.json

Forcing all connections to use the proxy via proxychains however works like a charm:

root@e9c0fed03724:/app# proxychains v8r -v .gitlab-ci.yml 
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/aarch64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.16
[proxychains] DLL init: proxychains-ng 4.16
ℹ No config file found
ℹ Merged args/config: {
  "_": [],
  "v": 1,
  "verbose": 1,
  "ignore-errors": false,
  "ignoreErrors": false,
  "cache-ttl": 600,
  "cacheTtl": 600,
  "format": "text",
  "$0": "/usr/local/bin/v8r",
  "patterns": [
    ".gitlab-ci.yml"
  ]
}
ℹ Processing ./.gitlab-ci.yml
ℹ Cache miss: calling https://www.schemastore.org/api/json/catalog.json
[proxychains] Strict chain  ...  192.168.5.2:8888  ...  www.schemastore.org:443  ...  OK
ℹ Cache miss: calling https://json.schemastore.org/schema-catalog.json
[proxychains] Strict chain  ...  192.168.5.2:8888  ...  json.schemastore.org:443  ...  OK
ℹ Searching for schema in https://www.schemastore.org/api/json/catalog.json ...
ℹ Found schema in https://www.schemastore.org/api/json/catalog.json ...
ℹ Cache miss: calling https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json
[proxychains] Strict chain  ...  192.168.5.2:8888  ...  gitlab.com:443  ...  OK
ℹ Validating ./.gitlab-ci.yml against schema from https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json ...
✔ ./.gitlab-ci.yml is valid

Unfortunately there is no easy way to install and run proxychains when running v8r within megalinter as we do in our CI.

As the used http lib got supports using a proxy I wondered if there's any way to use that.

Thank you very much!

RFC: Multidoc YAML support

I fell in love with LSPs using schemastore so I am trying to convince my devops team to use this project in their CI/CD for schema validation.

My target files was almost exclusively multidoc YAML files so I modified the cli.js and parser.js to support multidoc YAML files.

Would you want this functionality contributed back? If so, I can discuss further and open a PR.

npm run v8r catalog-info.yaml

> [email protected] v8r
> src/index.js catalog-info.yaml

ℹ No config file found
ℹ Processing ./catalog-info.yaml
ℹ Found schema in https://www.schemastore.org/api/json/catalog.json ...
ℹ Validating ./catalog-info.yaml against schema from https://json.schemastore.org/catalog-info.json ...
ℹ parsed yaml file as a multi-yaml doc
✔ ./catalog-info.yaml[0] is valid

✔ ./catalog-info.yaml[1] is valid

Run tests on multiple node versions

package.json declares compatibility with node >=12

v8r/package.json

Lines 45 to 47 in 9b44193

"engines": {
"node": ">= 12"
},

but at the moment the test suite only runs on the GH Actions default node version (which I think is now 14)

Set up a build matrix and run the test suite on

  • node 12 (until Apr 2022)
  • node 14
  • node 16

Bug: take in account * in schema filenames

Some schemas contain fileMatch with * caracter

Example:
image

v8r only checks for identical file name

To reproduce:
v8r json_good_1.cf.json

Cloudformation schema should be found but is not:

❌ Could not find a schema to validate json_good_1.cf.json

Support for ajv --all-errors option

ajv allows you to collect all validation errors before returning a validation failure result by including the "--all-errors" option on the cli. Any chance this option could be incorporated into v8r?

Allow v8r settings to be stored in a config file

In #110 @nvuillam suggested

Local cosmiconfig-like file would indeed be nice


I've been having a think through what data points need to go in this (although I have yet to consider syntax or implementation)

  • include/exclude globs (e.g: include: ['*.json', '*.yaml'], exclude: ['node_modules/'])

  • cache-ttl

  • ignore-errors

  • V8R_CACHE_NAME

  • catalogs: This should be a lot like a custom catalog, but with (at least) 2 custom extensions:

    Probably call this setting something other than catalogs to make it clear it is not a catalog

Define a JSON schema for .v8rrc so it can be validated.

how to enable allowUnionTypes?

I got error like

  strict mode: use allowUnionTypes to allow union type keyword at "https://json.schemastore.org/appsettings.json#" (strictTypes)

thanks!

Unable to stop `--catalogs` option from parsing filename

When I try to run something like:
v8r --catalogs catalog.json -- file.json

I get the help message, plus the error:
Not enough non-option arguments: got 0, need at least 1

I expected that it should be possible to put options before the filename positional argument, and indeed the following works:
v8r --catalogs catalog.json -v file.json

I suspect the error has something to do with the Yargs configuration. The array() docs state that it should be possible to indicate the end of an array of values with --, but that doesn't seem to be working. Maybe it's a bug upstream?

I also think the help message could be improved here. Most users aren't aware that -- is how most CLI frameworks have users escape array option parsing. I think that should either be mentioned, or the default changed so that you have to specify --catalogs catalog1.json --catalogs catalog2.json to use multiple catalogs, which feels like an uncommon case.

migrate from CommonJS to ESModules

  • Migrate from CommonJS to ESModules
  • Do I need to require node>=14 to do this, or can I continue to allow node>=12?
  • We are starting to see some dependencies which now require ESM e.g: #140

Cache schema catalog

@nvuillam wrote in #3

Add some cache management to avoid downloading schemas catalog for each v8r call

Currently I call https://www.schemastore.org/api/json/catalog.json every time we invoke v8r and then a second call to fetch the schema itself if we find one (plus any needed to resolve external references). As noted, probably the biggest performance win would be to store a local cache of the schema catalog. Then if we need to make several calls in a row e.g:

v8r file1.yml`
v8r file2.json
v8r file3.yaml

every call after the first will be a bit faster. If we make lots of calls that use the same schema, the schema itself would still be fetched on every request, but caching the catalog is the easy win.

Another semi-related thought: At the moment it is only possible to validate one file at a time. If it were possible to invoke v8r with multiple files, a directory or a glob pattern e.g:

  • v8r file1.yml file2.json file3.yaml
  • v8r directory/
  • v8r directory/**/*.yml

I could validate multiple files in one execution, store the schema catalog (and any schemas used) in memory for the duration of the execution without worrying about cache invalidation (a notoriously easy topic). This would be good for performance. Is it that useful to try to validate lots of different files at once though? How would I reduce a result like "these 3 files were valid, this other one failed and I couldn't find a schema for these two" to an exit code?

schema with key or id "https://json-schema.org/draft/2019-09/schema" already exists

Trying to lint a docker-compose.yml file:

 Processing docker-compose.yml
ℹ Cache miss: calling https://json.schemastore.org/schema-catalog.json
ℹ Searching for schema in my-catalog.json ...
ℹ Found schema in my-catalog.json ...
ℹ Cache miss: calling https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json
ℹ Validating docker-compose.yml against schema from https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json ...
ℹ Cache miss: calling http://json-schema.org/draft/2019-09/schema
✖ schema with key or id "https://json-schema.org/draft/2019-09/schema" already exists

I get exit code 1 because of this.

uses latest 3.1 OpenAPI schema for 3.0 openapi.yaml file

Scenario

You have an openapi.yaml file which starts with

openapi: 3.0.1
# [...]

When running v8r:

ℹ Processing openapi.yaml
ℹ Found schema in https://www.schemastore.org/api/json/catalog.json ...
ℹ Validating openapi.yaml against schema from https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json ...

# [...]

openapi.yaml#/openapi must match pattern "^3\.1\.\d+(-.+)?$"

References

https://www.schemastore.org/api/json/catalog.json contains:

{
  name: "openapi.json",
  description: "A JSON schema for Open API documentation files",
  fileMatch: [
    "openapi.json",
    "openapi.yml",
    "openapi.yaml"
  ],
  url: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json",
  versions: {
    3.0: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json",
    3.1: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"
  }
}

Schemas on schemastore with known issues

TODO: can any of these be fixed either in this lib or upstream?

Maximum call stack size exceeded

404: Not Found

Some variation of unknown format...

Other issues

Azure pipelines invalid escape

@chris48s I don't understand what is going on, I don't know if the error is in my file or in the schema itself (the url you mention).

My azure-pipelines.yml file should not be because it validates and runs correctly in Azure DevOps.

ℹ Processing .\azure-pipelines.yml
ℹ Found schema in .v8rrc.yml ...
ℹ Validating .\azure-pipelines.yml against schema from https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json ...
✖ Invalid regular expression: /^[^\/~\^\: \[\]\\]+(\/[^\/~\^\: \[\]\\]+)*$/: Invalid escape

Write a regression test for `resetCounters` behaviour

I added this in f59bf3b to reset the counters after we've finished validating each file. Without it, callLimit is applied across multiple file validations. I didn't add a test for it though.

TODO: Add a test (at cli level) that validates 11 files and asserts we can call a mock https://www.schemastore.org/api/json/catalog.json 11 times (rather than throwing Called https://www.schemastore.org/api/json/catalog.json >10 times. Possible circular reference).

New parameter --catalogs

By default v8r uses catalog fetched from schemastore, and it's great

But what if someone wants to validate using another catalog (using the same format), who could be in the same repository ?

To do that, we could add a parameter --catalogs: a comma separated list (usually just one item) with relative path or URL to another json-schema-catalog.json, and its content would be added (with priority) to schemastore catalog

Accept directory or glob pattern for filename param

At the moment it is only possible to validate one file at a time. If it were possible to invoke v8r with multiple files, a directory or a glob pattern e.g:

  • v8r file1.yml file2.json file3.yaml
  • v8r directory/
  • v8r directory/**/*.yml

I could validate multiple files in one execution.

Question: How do I reduce a result like "these 3 files were valid, this other one failed and I couldn't find a schema for these two" to an exit code? Have a look how ajv-cli does it. That is probably a good source of inspiration.

Ajv 7

Unfortunately upgrading isn't a straight no-brainer because Ajv 7 adds compatibility with draft-2019-09 but drops support for draft-04. Need to do a bit of research: Which are there more of on schemastore? Schemas using draft-2019-09 or draft-04 ?

Allow schema param to be a local file

I was a bit resistant to this initially, but v8r localfile.json --schema https://arbitrary.url/schema.json isn't really conceptually much different to v8r localfile.json --schema /path/to/localschema.json. Might as well do it at some point.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.