Skip to main content

Validation

dabke validates schedules at two stages: before solving (compilation) and after solving (result analysis). The validation system reports coverage gaps, rule violations, and solver errors in a structured format.

Compilation validation

ModelBuilder.compile() returns a validation field alongside the solver request:
const { request, canSolve, validation } = builder.compile();

if (!canSolve) {
  // Validation found errors that make solving impossible
  console.error(validation);
}
The canSolve flag is false when there are structural errors — for example, coverage requirements that reference roles no employee has.

Post-solve validation

After solving, parseSolverResponse checks the actual assignments against the original rules and coverage:
const result = parseSolverResponse(response);

// result.status — OPTIMAL, FEASIBLE, INFEASIBLE, TIMEOUT, or ERROR

Validation structure

The ScheduleValidation object contains three categories:

Coverage validation

Checks whether coverage requirements were met:
  • Passed — the required number of employees was assigned
  • Violation — fewer employees than required (but not zero)
  • Error — no employees assigned at all

Rule validation

Checks whether scheduling rules were satisfied:
  • Passed — rule was fully satisfied
  • Violation — soft rule was violated (the solver traded it off against other constraints)
  • Error — mandatory rule was violated (should not happen with a valid solution)

Solver errors

Issues from the solver itself — timeouts, infeasibility, etc.

Summarizing validation

Use summarizeValidation to get a human-readable summary:
import { summarizeValidation } from "dabke";

const summaries = summarizeValidation(validation);
for (const summary of summaries) {
  console.log(`${summary.label}: ${summary.status}`);
  for (const detail of summary.details) {
    console.log(`  - ${detail}`);
  }
}

ValidationReporter

For programmatic access during compilation, the ValidationReporter interface lets rules report issues as they compile:
reporter.addCoverageError({
  day: "2026-02-09",
  message: "No employees with role 'chef' available",
});
The ValidationReporterImpl class collects these reports and produces the final ScheduleValidation object.