Grokzen / pykwalify

Python YAML/JSON schema validation library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support multiple data type

anjankarpak96 opened this issue · comments

Environment

I am running PyKwalify on my Python file in PyCharm. I am using PyKwalify to validate my yaml file and then run the SQL scripts in Snowflake.

  • Python version: 3.8
  • PyKwalify version: 1.7.0

Steps to Reproduce

I want the schema to support multiple data types. My schema object should accept a string as well a list.

Schema

- Schemas:
            - TPCH_SF001
          ObjType:
            - TABLES
            - VIEWS
- Schemas:
             - TPCDS_SF10TCL
          ObjType: all

Data

                                       type: map
                                          matching-rule: 'any'
                                          mapping:
                                            type: seq
                                            sequence:
                                              - type: str
                                            type: map
                                            mapping:
                                              type: str
                                              enum: ['all']

Expected Behavior

The schema should accept both list and string data type. The only string value is 'all'.

Observed Behavior

It throws an error showing that the YAML file doesn't support duplicate keys.

This basicaly falls in under the existing request #112 which would implement basically the same kind of logic where you can define multiple paths for a single validation. There are plans for implementing this but not in the short term at least. Probably for version 2.0 this will be included.