Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All children inherit parent invalidations #699

Open
RivenSkaye opened this issue Nov 8, 2024 · 0 comments
Open

All children inherit parent invalidations #699

RivenSkaye opened this issue Nov 8, 2024 · 0 comments

Comments

@RivenSkaye
Copy link

RivenSkaye commented Nov 8, 2024

Having a schema that disallows additional properties in every level of nesting and then adding an additional property in the parent element makes Taplo (both the VSC extension and the CLI lint) repeat the error for that single disallowed value on every level of children and all of their properties.

MRE:
schema

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "additionalProperties": false,
    "title": "config.toml",
    "description": "A schema to validate against my own stupidity.",
    "type": "object",
    "properties": {
        "db": {
            "additionalProperties": false,
            "description": "Database Configuration",
            "type": "object",
            "properties": {
                "mysql": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                        "pool": {"type": "boolean"},
                        "other": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties" : {
                                "database": {"type": "string"}
                            }
                        }
                    }
                },
                "postgres": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                        "pool": {"type": "boolean"},
                        "other": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties" : {
                                "database": {"type": "string"}
                            }
                        }
                    }
                },
                "sqlite": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                        "wal_mode": {"type": "boolean"},
                        "other": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties" : {
                                "db_file_path": {"type": "string"}
                            }
                        }
                    }
                }
            }
        }
    }
}

toml

[db]
hodor = true  # invalid property, should only generate one warning, 2 if value validation still happens

# Every single key and value below this is being reported on,
# with the error that 'hodor' was unexpected!
[db.mysql]
pool = true
# moving hodor here makes only the db.mysql tree error out the wazoo
[db.mysql.other]
database = "mysuperawesomedb"

[db.postgres]
pool = true
[db.postgres.other]
database = "mysuperawesomedb"

[db.sqlite]
wal_mode = true
[db.sqlite.other]
db_file_path = "/my/super/awesome.db"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant