Skip to content

Implement schema validation for extracted data and integrate into controller pipeline with unit tests#301

Open
ayushhbasu wants to merge 8 commits intofireform-core:mainfrom
ayushhbasu:add-basic-validation
Open

Implement schema validation for extracted data and integrate into controller pipeline with unit tests#301
ayushhbasu wants to merge 8 commits intofireform-core:mainfrom
ayushhbasu:add-basic-validation

Conversation

@ayushhbasu
Copy link

@ayushhbasu ayushhbasu commented Mar 20, 2026

Description

This PR introduces a validation layer for extracted form data to ensure structural correctness before downstream processing.

A new utility function validate_extracted_data has been implemented to validate required fields (e.g., patient_name, age, diagnosis) and detect missing or empty values.

The validation logic is integrated into the controller pipeline, ensuring invalid data is caught early and handled via explicit exceptions. This improves overall system reliability and prevents propagation of malformed data into the PDF form-filling stage.

Additionally, unit tests have been added to cover both valid and invalid scenarios, including missing fields and empty values.

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 validation logic has been verified using unit tests covering multiple scenarios:

  • Valid input passes validation
  • Missing required fields fail validation
  • Empty field values fail validation
  • Controller raises exception on invalid data (via mocked dependency)

Steps to reproduce:

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

Test Configuration:

  1. Firmware version: N/A
  2. Hardware: N/A
  3. 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 fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Adds a function to validate required fields in extracted data.
Integrate validation into controller flow
Add unit tests for validation utility
Add a test for form validation failure in Controller. dd validation + tests
Add a test to validate form filling failure.
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