23andMe / Yamale

A schema and validator for YAML.
MIT License
666 stars 88 forks source link

include('xxx') does not check for existence of xxx #236

Closed Bascy closed 3 months ago

Bascy commented 6 months ago

I have noticed if I use include('xxx') in an any() validation, that it will not complain if the xxx does not exists at all. Is this by design?

nbaju1 commented 5 months ago

Could you provide examples of a yaml file and a schema to better illustrate your question?

Bascy commented 5 months ago

I've managed to recreated a simple example demonstrating the problem. It seems that the missing include is reported when other errors are present

Schema:

nodes: map(include('node'), key=str(), required=False)
---
node: >
  any(
  include('Node1'),
  include('Node2'), 
  )
---
Node1:
  type: str(equal='Node1')
  id1: int()

Succeeding yaml file:

nodes:
  name:
    type: node2
    id1: 123

Failing yaml file:

nodes:
  name:
    type: node2

Errors:

nodes.name.id1: Required field missing Include 'Node2' has not been defined.

Bascy commented 3 months ago

Any news on this issue?

cblakkan commented 3 months ago

Not by design but does seem minor since this will correctly not error in the case that none of the files being validated ever need the undefined include. Will consult internally on fixing this and report back.

cblakkan commented 3 months ago

I've merged a change to make this always fail when there's an undefined type. Will go out soon in the next release.

Bascy commented 3 months ago

Thanks!