Define ReportPeriodValidator interface and rule set
epic-bufdir-report-period-selection-services-task-004 — Define the ReportPeriodValidator abstract interface with a validate(DateTimeRange range, String orgId) method returning a sealed ValidationResult (valid / invalid with typed error codes). Document the three Bufdir structural rules it must enforce: (1) range must align to complete calendar-month boundaries, (2) range duration must be non-zero, (3) range must not overlap any previously submitted report period for the same organisation.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
Use Dart 3 sealed classes: `sealed class ValidationResult {}`, `final class ValidationSuccess extends ValidationResult {}`, `final class ValidationFailure extends ValidationResult { final ReportPeriodValidationError error; final DateTimeRange? conflictingPeriod; }`. Place the interface in `lib/features/bufdir/report_period/domain/report_period_validator.dart`. Keep the enum definition in the same file to avoid circular imports.
The method signature should be `Future
Testing Requirements
No tests required for this task — it is a pure interface/type definition. However, ensure the exported symbols are importable from the barrel file used by the BLoC layer so downstream test tasks can import without path hacks.
A compile-time check (dart analyze) is sufficient acceptance gate.
Detecting overlap with previously submitted reports requires querying a report history table that may not yet exist or may not have a reliable submitted_at / period_end field, making the validator dependent on an incomplete upstream feature (Bufdir Report History & Audit Log).
Mitigation & Contingency
Mitigation: Define the minimum interface (a single repository method: getSubmittedPeriods(orgId) → List<DateTimeRange>) as an abstract class in this epic. Implement a stub that returns an empty list until the history feature is available, so the validator compiles and passes tests without a real data source.
Contingency: If the history feature is delayed beyond this feature's delivery window, ship the validator with the stub returning an empty list (overlap check disabled) and surface a feature-flag-controlled warning banner explaining that overlap detection will be enabled in a future update.
Bufdir's structural requirements for reporting periods (complete calendar months, grant-year span restrictions) may be ambiguous or subject to change, causing the validator to enforce rules that are incorrect or overly restrictive for some organisations.
Mitigation & Contingency
Mitigation: Document the specific Bufdir rules being enforced in the validator's source code as named constants with references to the relevant Bufdir guidelines. Review the rules with at least one coordinator representative before implementation is finalised.
Contingency: Expose a per-org configuration flag (strict_bufdir_validation: bool) in the period configuration repository so that rule enforcement can be relaxed for specific organisations without a code deployment.