test: close the remaining FE/BE seams (WP-75)
Three seams WP-71 documented but left unguarded.
Deletes the FE's isHerregistratieEligible and isStatusConsistent — both
uncalled, the first dead by its own doc-comment. Their tests used fixtures
completely disjoint from the backend's (the backend even had an exact-window
boundary case the FE lacked), so the two sides could diverge indefinitely
without failing anything. CLAUDE.md's policy of keeping server-owned rules
as FE "reference impls" is what kept them alive, so it is amended: the FE may
mirror a server-supplied value for instant feedback, never reimplement the
algorithm. registration.policy.ts keeps its three live exports.
check-seam.sh now also guards the Besluit tag list — the C# enum and the TS
BESLUIT_TAGS array are identical ordered name lists with nothing linking
them, and Enum.TryParse fails at request time rather than build time. Anchored
on the full declaration so it avoids the "greps all matches" trap WP-69 hit.
The phone-format divergence turned out to be real, not latent as recorded:
the backend returned 422 for +31612345678 and (06) 12345678, both of which
the FE's own parseTelefoonnummer accepts. A grep check would have compared
the shared ^0\d{9}$ regex and reported all clear — the difference was in
stripping. RejectPhoneChange now strips what the FE strips, pinned by a
contract test.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,14 +21,21 @@ public static class SubmissionRules
|
||||
|
||||
private static readonly Regex PhonePattern =
|
||||
new(@"^0\d{9}$", RegexOptions.Compiled);
|
||||
private static readonly Regex StrippedChars =
|
||||
new(@"[\s\-()]", RegexOptions.Compiled);
|
||||
private static readonly Regex LeadingCountryCode =
|
||||
new(@"^\+31", RegexOptions.Compiled);
|
||||
|
||||
// RULE: a contact change needs a well-formed Dutch phone number (10 digits, leading
|
||||
// 0, formatting stripped). The BRP address is authoritative and cannot be changed
|
||||
// here (WP-34), so only the phone is submitted. The server re-validates format
|
||||
// authoritatively (the FE check is UX-only).
|
||||
// authoritatively (the FE check is UX-only) — and must strip the SAME formatting the
|
||||
// FE's parseTelefoonnummer does (whitespace/dashes/parens, a leading +31 → 0; WP-75),
|
||||
// or the two sides disagree on what's a valid number.
|
||||
public static string? RejectPhoneChange(string telefoon)
|
||||
{
|
||||
var digits = (telefoon ?? "").Trim().Replace(" ", "").Replace("-", "");
|
||||
var stripped = StrippedChars.Replace((telefoon ?? "").Trim(), "");
|
||||
var digits = LeadingCountryCode.Replace(stripped, "0");
|
||||
if (!PhonePattern.IsMatch(digits)) return "Voer een geldig telefoonnummer in, bijv. 0612345678.";
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user