Skip to content

fix: client _valid was permanently false for match: constraints - #131

Merged
pinetops merged 1 commit into
mainfrom
fix/match-constraint-valid-js
Aug 21, 2026
Merged

pinetops merged 1 commit into
mainfrom
fix/match-constraint-valid-js

Conversation

@pinetops

Copy link
Copy Markdown
Member

Closes #124 — the confirmed bug from the duplication audit.

validation_js.ex emitted ("pattern").match(value) — String.prototype.match invoked on the pattern with the user's value as the regex — so the generated <form>_<field>_valid derive returned false for valid and invalid input alike whenever the Ash attribute had a match: constraint. The _errors generator 70 lines below always had it right (new RegExp(pattern).test(value)), as did the server closure.

Why it stayed hidden: _valid mostly reaches the DOM via data-lavash-enabled, which only disables — a stuck-false valid renders as "button greyed until the round-trip lands", indistinguishable from latency. Same shape as the array-className bug: a special-case mechanism masking a general-case defect.

Standing guard (per the audit): a Deno-executed agreement suite asserting _valid is true exactly when _errors is empty, for valid and invalid input, across match: and integer min/max constraints. Verified to fail against the old code.

This suite also becomes the safety net for #125 (consolidating the three validation implementations onto the rx path).

🤖 Generated with Claude Code

#124)

validation_js.ex emitted ("pattern").match(value) — String.prototype
.match invoked ON the pattern string with the user's value as the
regex — so the generated <form>_<field>_valid derive returned false
for valid and invalid input alike whenever the Ash attribute had a
match: constraint. The _errors generator 70 lines below always had
it right (new RegExp(pattern).test(value)), as did the server.

Masked because _valid mostly reaches the DOM via
data-lavash-enabled, which only disables: a stuck-false valid looks
exactly like waiting on the round-trip. Found by the duplication
audit (special case hiding a general-case bug — the same shape as
the array-className fix).

Standing guard added per the audit: Deno-executed agreement tests
asserting _valid is true exactly when _errors is empty, for valid
AND invalid input, across match: and integer min/max constraints.
The match: case fails against the old code.
@pinetops
pinetops merged commit 9e952ea into main Aug 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: client _valid stuck false for any match: constraint (inverted regex call)

1 participant