-
Notifications
You must be signed in to change notification settings - Fork 84
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
Allow key to be specified or left empty #53
Comments
@smalleni Can you provide the schema/data you are having problems with or can you provide an example schema/data that breaks? Would make it easier to help. |
So, I'm using pykwalify to verify the configuration file I am passing to a test suite. Example scenario file:
So my question is how do I write the schema file to ignore say "rally" if the scenario file doesnt contain "rally". This is more of a question rather than an issue maybe. Sorry. |
It sounds like you are looking for conditional validation and there is already a similar issue for that here #35 where you can read up on some of the things i suggested over there. The short answer is that there is no direct support for simple conditional validation where you can say However, if you want to test a middle ground that i think might work for your case, it could be to use the # Data
rally:
enabled: true
sleep_before: 5
sleep_after: 5
perfkit:
enabled: true
sleep_before: 0
sleep_after: 0
venv: /home/stack/perfkit-venv/bin/activate
default:
image: centos7
machine_type: m1.small
# Schema
type: map
mapping:
rally:
required: False
type: map
allowempty: True
shaker:
required: False
type: map
allowempty: True
perfkit:
required: False
type: map
allowempty: True With this, i could for example remove the |
@Grokzen ..thanks for the detailed explanation. Appreciate it |
No problems :) If you find a solution that works, pleas share it and close the issue if it works. |
@Grokzen ..just another question..my scenario file has a list of dictionaries and the keys could be different each time, so i don't want to test for names but just want to check if the the sequence is a list of dictionaries.
Validation throws an exception, looks like the key values are being expected for the mapping. Anyway to get around this? |
Yeah, that looks more like a bug. There are some special cases and processing that is done when a map is found inside a sequence and it could be a missed case that is not working properly. I will add it to my TODO list :) |
@Grokzen I can open an issue for that if that helps. Thanks. |
Is this feature present in the current release?
I am using a single schema file to validate against different scenarios. Some of the scenarios have a specific key and some don't. I would like to be able to specify in the schema to ignore if the key isn't present.
The text was updated successfully, but these errors were encountered: