23andMe / Yamale

A schema and validator for YAML.
MIT License
680 stars 89 forks source link

Conditional with strict #92

Closed devlucasc closed 4 years ago

devlucasc commented 4 years ago

I can't validate a schema like this: Data 1:

id: example
type: type1
value: 10

Data 2:

id: example
type: type2
value: value

Schema:

any(include('v1'), include('v2), include('v3'))
---
v1:
  id: str()
---
v2:
 type: regex('^type1')
 value: int()
---
v3:
 type: regex('^type2')
 value: str()

I was only able to do that when I duplicated schema like this:

any(include('v2), include('v3'))
---
v2:
 id: str()
 type: regex('^type1')
 value: int()
---
v3:
 id: str()
 type: regex('^type2')
 value: str()

This occurs because validator in any operator are validated separatedely. I would like to make a conditional schema validator, defined by the type field

mildebrandt commented 4 years ago

Duplicate of #91