Repository navigation
fix: client _valid was permanently false for match: constraints - #131
Merged
Merged
Conversation
#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #124 — the confirmed bug from the duplication audit.
validation_js.exemitted("pattern").match(value)—String.prototype.matchinvoked on the pattern with the user's value as the regex — so the generated<form>_<field>_validderive returned false for valid and invalid input alike whenever the Ash attribute had amatch:constraint. The_errorsgenerator 70 lines below always had it right (new RegExp(pattern).test(value)), as did the server closure.Why it stayed hidden:
_validmostly reaches the DOM viadata-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
_validis true exactly when_errorsis empty, for valid and invalid input, acrossmatch:and integermin/maxconstraints. 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