Skip to content

Add validation for ContractConfig and DiagramConfig #17

@Michael628

Description

@Michael628

Parent PRD

#15

What to build

Add validate_config functions for ContractConfig and DiagramConfig that reject invalid empty collections, and register them via validate=validate_config in their register_task calls.

pyfm/tasks/contract/contraction.py:

  • Add validate_config(config) that raises ValueError if config.diagrams is an empty dict

pyfm/tasks/contract/diagram.py:

  • Add validate_config(config) that raises ValueError if config.mesons is an empty list

Tests:

  • Test that building ContractConfig with empty diagrams raises a validation error
  • Test that building DiagramConfig with empty mesons raises a validation error

Acceptance criteria

  • ContractConfig validation rejects empty diagrams dict with clear error message
  • DiagramConfig validation rejects empty mesons list with clear error message
  • Validation functions registered via validate=validate_config in register_task
  • Tests cover both valid and invalid cases
  • Existing tests still pass

Files in scope

  • pyfm/tasks/contract/contraction.py (modify)
  • pyfm/tasks/contract/diagram.py (modify)
  • test/tasks/contract/test_contraction.py (modify or create)
  • test/tasks/contract/test_diagram.py (modify or create)

Implementation guardrails

  • Delete means delete. If this issue says to remove something, remove it entirely. Do not preserve the removed functionality in a different form (e.g. extracting it into helper functions or a new module) unless explicitly instructed.
  • Preserve semantics when substituting. When replacing one pattern with another, verify the replacement has the same observable behavior: copy vs. mutate, return value, side effects. If the old code created a copy, the new code must also create a copy.
  • No drive-by improvements. Do not refactor, reformat, or "improve" code that is not directly related to the acceptance criteria. No import reordering, no style changes, no new abstractions.

Blocked by

User stories addressed

  • User story 6 (reject empty diagram/meson collections)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions