Skip to content

Function aware schema validation rules #3672

@kddejong

Description

@kddejong

Is this feature request related to a new rule or cfn-lint capabilities?

New capability

Describe the feature you'd like to request

Currently when doing custom rules with JSON schema based validation we do strict type checking which means we don't handle conditions well or will skip those custom rules when run into functions like Fn::If. To increase coverage of these tests it would be awesome if we could build checks that are condition aware.

Describe the solution you'd like

This typically comes up when we are looking for property changes as a result of a value of another property.

{
  "if": {
    "properties": {
      "Foo": {
        "enum": ["A"]
       }
    },
    "required": ["Foo"]
  },
  "then": {
     "required": ["Bar"]
  }
}

If Foo and Bar have Fn::If values we currently skip validation. What we need to be able to do is validate the true/false path of each properties value combined together. While this schema is simple it gets more complicated if we are evaluating many properties or keywords in the "if"

Additional context

Whatever mechanism we come up with should be able to converted to JSON schema draft 7 so we can continue to create valid schemas that can be used other processes. In these scenarios the functions would be resolved allowing us to do a more direct validation.

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request

Would this feature include a breaking change?

  • ⚠️ This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions