A citation requirement that applies to every record is a requirement nobody meets. So in our open-source project jobpostrules, only one kind of rule has to prove where it came from.
Every rule in the registry carries a status. Advisory, unverified, pending: those may cite anywhere, or nothing at all. Only in-force rules, the single status our severity map turns into an error, must point at an allowlisted source. That check runs last in the validation chain, and only when the status is in-force and the citation URL is non-empty. The cost of strictness lands exactly where a rule can actually block a job post.
The allowlist is nineteen records, each a name, a host, and an optional path prefix: EUR-Lex, ISAP, Google's developer documentation host, Ontario scoped to /laws, and fifteen US state legislature hosts.
The lookup is deliberately unforgiving.
The URL goes through the URL constructor, and a parse failure is simply not a source.
The protocol has to be https, not http.
The lowercased hostname has to equal a listed host exactly. A suffix match would turn any subdomain into an official source, so a subdomain is not the host.
A path prefix, when present, matches only the pathname itself or the prefix followed by a slash. That is the detail a plain startsWith gets wrong: /lawsuit is not /laws.
The second decision is about reporting. We collect problems instead of throwing on the first one. A single rule can come back with an empty id, a citation missing its section, a verifiedAt that fails the ISO date check, an effectiveTo that sits before effectiveFrom, and a minHeadcount that is not an integer of at least 1, all from one pass. The registry walk adds ids used twice and returns pairs of rule id and problem. Shape-only rules stop after the id check, because none of the citation fields apply to them.
The practical effect is boring and valuable: fixing a bad data file is one editing session, not five runs of a failing build.
Both decisions come from the same idea. A validator is a tool for the person repairing the data, not a gate that enjoys saying no.
You draw your own line between fail-fast and collect-everything somewhere in your validation code, and we would like to hear where it sits.