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

Conditional Validation in CSV and JSON Schema #1726

Open
megin1989 opened this issue Jan 15, 2025 · 3 comments
Open

Conditional Validation in CSV and JSON Schema #1726

megin1989 opened this issue Jan 15, 2025 · 3 comments

Comments

@megin1989
Copy link

I am working on a schema that includes the following fields:

  • SEXUAL_ORIENTATION_VALUE_CODE
  • SEXUAL_ORIENTATION_VALUE_CODE_DESCRIPTION
  • SEXUAL_ORIENTATION_VALUE_CODE_SYSTEM_NAME
  • SEXUAL_ORIENTATION_LAST_UPDATED

I need to enforce a condition in the schema such that if the fields SEXUAL_ORIENTATION_VALUE_CODE and SEXUAL_ORIENTATION_VALUE_CODE_DESCRIPTION have values in the CSV file, then the field SEXUAL_ORIENTATION_LAST_UPDATED must also be mandatory.

Could you please guide me on how to achieve this using Frictionless validation? Specifically, I need the schema to enforce this rule during data validation.

Thank you!

@peterdesmet
Copy link
Member

It is currently not possible to specify conditional requirements, only atomical ones (not conditional on other fields): see constraints. I think you will need to write your own functions.

Conditional constraints are high on the demand list to be included in the specification though, but not straightforward to add. See frictionlessdata/datapackage#1058.

@megin1989
Copy link
Author

Thank you for your response. I’m awaiting further details on the conditions for the other fields.

@peterdesmet
Copy link
Member

I’m awaiting further details on the conditions for the other fields.

Can you clarify? What other fields?

For example, if you want to make sure that SEXUAL_ORIENTATION_VALUE_CODE always has a value, use:

[
  "name": "SEXUAL_ORIENTATION_VALUE_CODE",
  "constraints": {
    "required": true
  }
]

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