Skip to content

feat(validation): add context-aware postal code validators for UK, Canada, and Germany #512

Description

@JohnnyWilson16

Context

As outlined in the Contributor Roadmap (Level 2: Component Improvements), international tabular datasets frequently contain regional postal and zip codes. Adding dedicated validation support for common international formats helps users validate addresses and geographic fields safely without custom regex scripts.

Task

Implement context-aware postal code regex patterns in src/freshdata/fieldcheck.py for:

  1. United Kingdom (UK): e.g. SW1A 1AA, EC1A 1BB, W1A 0AX
  2. Canada: e.g. K1A 0B1, M5V 2T6
  3. Germany (PLZ): e.g. 10115, 80331 (5-digit numeric strings)

Add corresponding unit test cases in tests/test_fieldcheck.py to ensure valid codes pass, invalid patterns fail cleanly, and edge cases (lowercase, varying whitespace) are properly handled or normalized.

Acceptance Criteria

  • Add compiled regex patterns or helper functions in src/freshdata/fieldcheck.py supporting UK, Canadian, and German postal codes.
  • Integrate into validate_fields pattern matching or field specification lookup.
  • Add unit tests in tests/test_fieldcheck.py covering positive matches, negative matches, and edge cases.
  • Tests execute fast and pass cleanly with pytest tests/test_fieldcheck.py --no-cov.
  • Code adheres to style and type standards (ruff check . and mypy src/freshdata/fieldcheck.py).

Pointers


New to the codebase? Comment /assign to claim this issue! You can also check our First Contribution Guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions