-
Notifications
You must be signed in to change notification settings - Fork 60
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 extra keys in a yaml file #54
Comments
Possibly, yeah. I'll have a think about it.
Bear in mind that it's possible to use MapPattern(Str(), Any()) and then
use revalidation to tighten the screws on the schema for certain key/value
combinations.
…On Wed, 10 Apr 2019, 11:57 Krishan Bhasin, ***@***.***> wrote:
Currently, I am unable to set the equivalent to the json additionalProperties
= True schema property, getting the error message
unexpected key not in schema ''
Would it be possible to add an optional flag to allow/disallow this?
My use case is strictly specifying some fields within a larger yaml file
that I do not care about. I would be happy to contribute a PR if you are
able to help guide me to where to add this!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#54>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFyVNdxT3nw9vqFOugYyjyUg7Rmzf28Lks5vfcOQgaJpZM4cmtRc>
.
|
That's if you want a solution right now - I'm cognizant that this is not
necessarily the ideal solution to your problem.
…On Wed, 10 Apr 2019, 12:30 Colm O'Connor, ***@***.***> wrote:
Possibly, yeah. I'll have a think about it.
Bear in mind that it's possible to use MapPattern(Str(), Any()) and then
use revalidation to tighten the screws on the schema for certain key/value
combinations.
On Wed, 10 Apr 2019, 11:57 Krishan Bhasin, ***@***.***>
wrote:
> Currently, I am unable to set the equivalent to the json additionalProperties
> = True schema property, getting the error message
>
> unexpected key not in schema ''
>
> Would it be possible to add an optional flag to allow/disallow this?
>
> My use case is strictly specifying some fields within a larger yaml file
> that I do not care about. I would be happy to contribute a PR if you are
> able to help guide me to where to add this!
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#54>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AFyVNdxT3nw9vqFOugYyjyUg7Rmzf28Lks5vfcOQgaJpZM4cmtRc>
> .
>
|
I was hoping to try that (specify the my schema then add a MapPattern() that allows any other key/value pairs to exist) but I couldn't get that to work. Or am I misunderstanding your suggestion? |
@crdoconnor any chance you could point me in the direction of where I could make a PR to change this? |
I think I created a branch for this with a story. I'll double check later.
…On Mon, 13 May 2019, 16:10 Krishan Bhasin, ***@***.***> wrote:
@crdoconnor <https://github.com/crdoconnor> any chance you could point me
in the direction of where I could make a PR to change this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#54?email_source=notifications&email_token=ABOJKNI4TU2LSGWLUVJO5QLPVGAHXA5CNFSM4HE22ROKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVITZUQ#issuecomment-491863250>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABOJKNK4L4NFUNKVNNO7GCDPVGAHXANCNFSM4HE22ROA>
.
|
Hi @crdoconnor, any chance you could point me at where I can make the change to make a PR? |
I asked chatGPT: "in strictyaml , how to ignore unexpected keys?" In StrictYAML, you can use the allow_unused_keys option to ignore unexpected keys when parsing a YAML document. This option is set to False by default, which means that an error will be raised if the document contains any unexpected keys. To allow unexpected keys to be ignored, you can set the allow_unused_keys option to True when parsing the document. Here's an example:
In this example, we're parsing a YAML document that contains three keys (key1, key2, and key3). However, our schema only defines two of these keys (key1 and key2). By setting allow_unused_keys to True, we're telling StrictYAML to ignore any unexpected keys in the document and only validate the keys that are defined in the schema. When we run this code, we'll get the following output:
As you can see, the key3 key is ignored because it's not defined in the schema and allow_unused_keys is set to True. UNQUOTE |
Work-around:
|
Currently, I am unable to set the equivalent to the json
additionalProperties = True
schema property, getting the error messageWould it be possible to add an optional flag to allow/disallow this?
My use case is strictly specifying some fields within a larger yaml file that I do not care about. I would be happy to contribute a PR if you are able to help guide me to where to add this!
The text was updated successfully, but these errors were encountered: