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

Check if a key present in map #235

Open
nirupbbnk opened this issue Nov 23, 2023 · 1 comment
Open

Check if a key present in map #235

nirupbbnk opened this issue Nov 23, 2023 · 1 comment

Comments

@nirupbbnk
Copy link

properties:
caseID:
type: string
description: some description
detailed_goal:
type: string
description: some description for goal
context:
type: string
description: some description for context

This is my data , here i want to validate if map has key context , we want to check only if context is present , rest keys are dynamic and may change,
We want to validate only context key is present , rest keys can be anything,

properties: map(key=regex('context'))

Currently I am using this , but validation fails as it has other keys , (as other keys are dynamic we can't have static value )

@nbaju1
Copy link

nbaju1 commented Mar 12, 2024

Quite an old issue, but I believe this will do what you want:

Schema:

properties: include('props', required=True, strict=False)
---
props:
    context: include('cont', required=True)     
---
cont:
    type: str()
    description: str()    

This assumes your data is on the following form:

properties:
    context:
        type: string
        description: A string value
    other_key:
        type: string
        description: A string value

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

2 participants