Closed jiaorenyu closed 2 years ago
Hi, thanks for your interest in Yamale.
There is no ability to validate duplicated elements in a list with Yamale.
Hi, thanks for your interest in Yamale.
There is no ability to validate duplicated elements in a list with Yamale.
Thanks for the reply, can we support it in the future?
This use case may be too complex than what we'd like to support in Yamale. If it was as simple as detecting duplicate items in a list, then I think we could support it. For example, changing your sample slightly:
columns:
- name: n1
type: string
- gender: male
type: string
- gender: male
type: string
We have two items in the list that equal {gender: male, type: string}
. For your use case:
columns:
- name: n1
type: string
- gender: male
type: string
- gender: 1
type: int
There is one item of {gender: male, type: string}
and the other of {gender: 1, type: int}
. These would not be equal. You're looking to describe certain keys of a dictionary cannot be duplicated within a list, and I don't think that's something we can support while keeping the schema language simple enough.
You can write your own custom validator to support specific use cases: https://github.com/23andMe/Yamale#custom-validators
Please reach out if you have any problems writing your own validator.
I have a use case:
I want to check if there are some duplicated columns, I don't want it has duplicated columns.