Skip to content

Conditions edit in place, and validation speaks the builder's language - #24

Merged
AllTerrainDeveloper merged 1 commit into
mainfrom
feature/wysiwyg-conditions-and-validation
Aug 21, 2026
Merged

AllTerrainDeveloper merged 1 commit into
mainfrom
feature/wysiwyg-conditions-and-validation

Conversation

@AllTerrainDeveloper

Copy link
Copy Markdown
Owner

WYSIWYG conditions on the canvas

The "shown when" row on a card is now the editor for what it shows — nothing on it is inert text any more:

  • "Shown when" is a button: click to flip show ↔ hide.
  • The comparison ("is more than") is a small inline select of every operator, in plain words.
  • The answer is an editable chip — a text input sized to its content, or a select of the source field's choices where the question has choices (typing free text against a radio group could only produce a rule that never matches).
  • "and"/"or" between rules toggles all ↔ any.

Keystrokes write to the live rule and refresh the curve labels without rebuilding the DOM under the caret; the commit (change/blur) redraws everything and restores focus. Card gestures (drag, select, Backspace-to-delete) are fenced out of the row.

"The answer should be…" — validation presets

The raw regex "Pattern" box is replaced by a picker of 17 named answer shapes: email, phone, @handle, digits, decimal, price, US ZIP, UK postcode, IBAN, card number (Luhn-checked), letters, alphanumeric, one-word, URL, IP, slug, hex colour. Each preset is enforced identically by browser and server from twin tables (src/shared/validation.ts / includes/validation.php), with tests/fixtures/validation-cases.json as the shared conformance fixture both suites read — the tables cannot drift silently. Every preset's picker hint is its own passing example.

The custom-rule builder, with a playground

When no preset fits, "A custom rule…" opens a child window over the builder:

  • Easy blocks: starts with / ends with / must contain / must not contain / only these characters / length between — plain questions that compile into one anchored pattern via lookaheads. The compiled expression never appears in this tab.
  • In plain words: the rule reads itself back as a sentence ("The answer starts with "AT-", and is 5–8 characters long.").
  • Try it out: sample answers judged live (✓ passes / ✗ fails) as the rule is edited.
  • Expression (advanced): raw regex for experts, same playground.

The blocks persist as a whitelisted-normalised recipe (validationRecipe) so the editor reopens as it was left; the compiled pattern is what both engines enforce. A pre-existing hand-written pattern opens in the expert tab rather than starting from zero.

New filter: atf_validation_presets (documented in docs/hooks-reference.md, Experimental).

Tests

  • vitest: 337 pass (63 new preset conformance cases + compiler/parser/describe suite).
  • PHPUnit: 671 pass (fixture conformance, Luhn, schema round-trip, custom-message precedence).
  • QA'd live on the 8889 site: inline condition editing, preset picker, custom-rule window, playground verdicts, and the saved schema round-trip through atf_normalize_schema().

🤖 Generated with Claude Code

https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp

Two WYSIWYG moves in one change:

The "shown when" row on a canvas card is now the editor for what it
shows. The verb flips show/hide, the comparison is a small inline
select, the answer is an editable chip (a select of the source field's
choices where it has them), and "and"/"or" toggles how rules combine.
Curve labels and the inspector follow every keystroke.

The pattern box grew into an answer-shape system. A picker of 17
presets — email, phone, ZIP, IBAN, card number (Luhn-checked), and
more — enforced identically by browser and server from twin tables,
with tests/fixtures/validation-cases.json as the shared conformance
table neither side can drift from. When no preset fits, "A custom
rule…" opens a child window where plain-question blocks (starts with,
must contain, only these characters, length) compile into one pattern,
described back in plain words, with a live playground that judges
sample answers as the rule is edited. The blocks are stored as a
recipe (`validationRecipe`) so the editor reopens as it was left.

New hook: `atf_validation_presets` (documented, Experimental).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 6e99bf1 into main Aug 21, 2026
3 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.

1 participant