Skip to content

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

Closed

Description

@pinetops

lib/lavash/form/validation_js.ex:231 emits ("pattern").match(value || '') — String.prototype.match invoked on the pattern string with the user's value as the regex. Result: the generated <form>_<field>_valid derive is permanently false whenever the Ash attribute has a match: constraint — for valid and invalid input alike.

The _errors generator at :303 gets it right (new RegExp(pattern).test(value)), and the server closure (expand_fields.ex, String.match?/2) is also correct — so client _valid disagrees with both.

Why it stayed hidden (same shape as the array-className bug in #122): _valid reaches the DOM mostly via data-lavash-enabled, which only disables — a stuck-false valid renders as "button stays greyed until the server round-trip", indistinguishable from latency. Nothing in demo/ uses a match: constraint, so no e2e ever exercised it.

Fix: new RegExp(pattern).test(value) at :231. Add the standing guard the audit suggests: a test with a match:-constrained form comparing server _valid, client _valid JS, and client _errors for agreement on valid AND invalid input.

Activity

  1. added a commit that references this issue on Aug 21, 2026
    9e952ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions