framework icon indicating copy to clipboard operation
framework copied to clipboard

How to Show Errors for Required Fields but Warnings for Optional Fields in Frictionless?

Open megin1989 opened this issue 8 months ago • 0 comments


Description:

I am using Frictionless to validate CSV data with a schema, and I need to differentiate between errors and warnings based on the field type:

  1. For Required Fields (e.g., GENDER):

    • If the value is missing or does not match the enum, it should be treated as an error.
  2. For Optional Fields (e.g., EXTENSION_SEX_AT_BIRTH_CODE_VALUE):

    • If the format or enum does not match, it should be treated as a warning, not an error.
    • If the value is "male", it should also generate a warning instead of an error.

Schema Example (schema.json)

{
  "fields": [
    {
      "name": "GENDER",
      "type": "string",
      "description": "Bundle.entry.resource.where(resourceType ='Patient').gender",
      "constraints": {
        "required": true,
        "enum": ["male", "female", "other", "unknown"]
      }
    },
    {
      "name": "EXTENSION_SEX_AT_BIRTH_CODE_VALUE",
      "type": "string",
      "description": "Bundle.entry.resource.where(resourceType ='Patient').extension.where(url='http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex').valueCode",
      "constraints": {
        "enum": ["f", "m", "unk"]
      }
    }
  ]
}

Expected Behavior:

Field Issue Type Expected Output
GENDER is empty ❌ Error "GENDER is required"
GENDER is "invalid_value" ❌ Error "Invalid GENDER value"
EXTENSION_SEX_AT_BIRTH_CODE_VALUE is "wrong_value" ⚠️ Warning "Invalid EXTENSION_SEX_AT_BIRTH_CODE_VALUE"

Question:

🔹 Is there a native way in Frictionless to classify specific validation errors as warnings instead of errors?


Thanks in advance! 🚀

megin1989 avatar Feb 05 '25 14:02 megin1989