Enforce strict ZIP code validation in file ingestion to reject malformed addresses

Resolved 💬 2 comments Opened Dec 5, 2025 by asacurry-scribe Closed Feb 3, 2026

Project: SAM (Samples)
Assignee: Asa Curry
T-Shirt Size: XS (Extra Small)

Overview

The file ingestion flow processes ZIP codes without explicit enforcement. Addresses with malformed ZIP codes can pass through file processing and cause issues downstream when submitting orders to Lilly.

Problem Statement

  • Addresses with invalid ZIP codes (e.g., 123456789 without dash, 12345 6789 with space) may pass through file processing unchecked
  • No clear error messaging during file ingestion when ZIP codes don't match expected formats
  • The validation pattern ^\d{5}(-\d{4})?$ is defined but not consistently enforced during file import
  • Invalid data can propagate to Lilly API calls, causing rejections

Acceptance Criteria

  • [ ] File ingestion validates all ZIP codes match pattern: ^\d{5}(-\d{4})?$
  • [ ] Addresses with invalid ZIP codes are rejected with clear error messaging
  • [ ] Error includes: expected format, actual value, row/record number
  • [ ] Rejected addresses are logged and NOT imported into database
  • [ ] Validation applies to all address import sources

Implementation Notes

Key Files:

  • /Microservice.Samples.Lilly/Services/File/New/Common/ValidationConstants.cs - Regex pattern
  • /Microservice.Samples.Business/Validation/AddressValidator.cs - Validation logic
  • /Microservice.Samples.Lilly/Services/File/New/Models/Lily/AddressAdapter.cs:106 - CSV mapping
  • /Microservice.Samples.Lilly/Services/File/New/Common/ValidationHelpers.cs - Helpers

Constraint: Do NOT normalize/mutate ZIP codes - reject malformed data

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗