# json-schema-validator/no-invalid

validate object with JSON Schema.

  • ⚙️ This rule is included in "plugin:json-schema-validator/recommended".

# 📖 Rule Details

This rule validates the file with JSON Schema and reports errors.

Now loading...

# 🔧 Options

{
    "json-schema-validator/no-invalid": [
        "error",
        {
            "schemas": [
                {
                    "fileMatch": [".eslintrc.json"],
                    "schema": {/* JSON Schema Definition */} // or string
                }
            ],
            "useSchemastoreCatalog": true
        }
    ]
}
  • schemas ... Define an array of any JSON Schema.
    • fileMatch ... A list of known file names (or globs) that match the schema.
    • schema ... An object that defines a JSON schema. Or the path of the JSON schema file or URL.
  • useSchemastoreCatalog ... If true, it will automatically configure some schemas defined in https://www.schemastore.org/api/json/catalog.json (opens new window). Default true

This option can also be given a JSON schema file or URL. This is useful for configuring with the /* eslint */ directive comments.

Now loading...

# Use with .vue

This rule supports .vue custom blocks (opens new window).

Example:

<i18n>
{
    "en": {
        "hello": "Hello"
    }
}
</i18n>

You must also install eslint-plugin-vue (opens new window) to enable .vue files validation. See here (opens new window) for details.

To match a custom block, use a glob like this:

{
    // If you want to match the <i18n> block.
    "fileMatch": ["**/*blockType=i18n*"],
    "schema": { "type": "object" /* JSON Schema Definition */ }
}

The following custom blocks will try to test if it matches with the virtual filenames.

<i18n lang="yaml">
# path/to/foo.vue/i18n.yaml?vue&type=custom&blockType=i18n&lang=yaml
foo: bar
</i18n>

<i18n lang="json">
// path/to/foo.vue/i18n.json?vue&type=custom&blockType=i18n&lang=json
{ "foo": "bar" }
</i18n>

<i18n>
// path/to/foo.vue/i18n.json?vue&type=custom&blockType=i18n
{ "foo": "bar"}
</i18n>

# 📚 Further reading

# 🚀 Version

This rule was introduced in eslint-plugin-json-schema-validator v0.1.0

# 🔍 Implementation

Last Updated: 10/15/2021, 11:46:24 AM