Skip to content

Add configurable schema enforcement and structured JSON validation for extraction pipeline#303

Open
ayushhbasu wants to merge 11 commits intofireform-core:mainfrom
ayushhbasu:add-schema-validationV2
Open

Add configurable schema enforcement and structured JSON validation for extraction pipeline#303
ayushhbasu wants to merge 11 commits intofireform-core:mainfrom
ayushhbasu:add-schema-validationV2

Conversation

@ayushhbasu
Copy link

This PR builds on the basic validation layer by introducing schema-based enforcement,

making the pipeline more extensible for different agency requirements.

Description

This PR extends the existing validation layer by introducing schema-based enforcement for extracted data within the pipeline.

A centralized schema (REQUIRED_FIELDS) has been added in src/schema.py to define required fields along with their expected data types. The validation logic has been refactored to dynamically validate incoming structured data against this schema, ensuring both field presence and type correctness.

This change improves the flexibility and scalability of the system by enabling future support for agency-specific schemas without modifying core validation logic.

Additionally, test cases have been updated to align with the new schema and expanded to cover type validation scenarios, improving overall test coverage and robustness.

Fixes # (issue)


Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

The updated validation logic has been tested using unit tests covering the following scenarios:

  • Schema-compliant data passes validation
  • Missing required fields fail validation
  • Empty field values fail validation
  • Incorrect data types fail validation

Steps to reproduce:

  1. Navigate to the project root
  2. Run:
    pytest src/tests/
    

Test Configuration:

  • Firmware version: N/A
  • Hardware: N/A
  • SDK: Python 3.x, pytest

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

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

Successfully merging this pull request may close these issues.

1 participant