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

Subset not working with includes #230

Open
sbliven opened this issue Oct 24, 2023 · 3 comments
Open

Subset not working with includes #230

sbliven opened this issue Oct 24, 2023 · 3 comments

Comments

@sbliven
Copy link

sbliven commented Oct 24, 2023

The subset validator accepts both single items and lists when used with primitives. However it does not validate single objects when included.

schema.yaml

primative_list: subset(str())
primative_single: subset(str())
complex_list: subset(include('person'))
complex_single: subset(include('person'))
---
person:
  first: str()
  last: str()

test.yaml

primative_list:
- foo
- bar
primative_single: foo
complex_list:
- first: joe
  last: dread
- first: sam
  last: scott

# Should validate but doesn't
complex_single:
  first: fred
  last: jones

Errors

complex_single.last: Required field missing
complex_single.first: Required field missing

This seems potentially related to #133 and #217, which also involve errors when combining validators.

@fclante
Copy link

fclante commented Jun 28, 2024

Hey This is a big thing. Please prioritize this.

@HenrikDK
Copy link

HenrikDK commented Nov 8, 2024

We have a similar issue to this but in this case i believe its a mismatch between the schema intent and actual data structure.

subset validates a list so:

complex_single: subset(include('person'))

should be :

complex_single: any(include('person'))

@sbliven
Copy link
Author

sbliven commented Dec 3, 2024

@HenrikDK Your examples don't quite match the schema intent. I think you are suggesting this work-around:

complex_list: any(include('person'), list(include('person')))
complex_single: any(include('person'), list(include('person')))

While this works, it's much more verbose than subset.

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

3 participants