framework icon indicating copy to clipboard operation
framework copied to clipboard

Requiring oneOf or anyOf two fields/columns

Open kgeographer opened this issue 2 years ago • 1 comments

Overview

I'd like to require that a tabular data file include one of two fields, each with its own name, description, and pattern constraint. I'm currently using v3.31.0; I would gladly update the version but don't see a way to do this, for example with a oneOf or anyOf constraint in place of required. Is this possible?

kgeographer avatar Feb 24 '23 17:02 kgeographer

Hi @kgeographer,

It's currently not possible. I think the best solution will be using Python to check this:

resource = Resource.describe('table.csv')
assert resource.schema.has_field('name1') or resource.schema.has_field('name2')
# TODO: other logic

I'll mark this issue as a feature request as well

roll avatar Feb 28 '23 10:02 roll