Skip to content

feat(toolbar): validate enum props, throw on invalid values#25

Merged
zachiler merged 3 commits into
devfrom
feature/toolbar-enum-validation
Jun 7, 2026
Merged

feat(toolbar): validate enum props, throw on invalid values#25
zachiler merged 3 commits into
devfrom
feature/toolbar-enum-validation

Conversation

@zachiler

@zachiler zachiler commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

Hardens the toolbar components so invalid enum values fail loudly instead of silently degrading (follow-up to #22, where docs had wrongly listed align="left/right" — which the component passed through as an Alpine modifier and silently centered).

<x-flow-toolbar> and <x-flow-edge-toolbar> now validate in the constructor against backed enums and throw InvalidArgumentException naming the valid values:

  • positiontop/bottom/left/right
  • aligncenter/start/end
  • showselected/always

New ToolbarPosition / ToolbarAlign / ToolbarShow enums + a shared ValidatesEnumProps concern. Scalar-typed props (offset, edge position, below) are already type-enforced — unchanged.

Alpha-breaking: a page passing an invalid value now errors rather than silently centering. Acceptable per the alpha CHANGELOG convention; chosen over a graceful fallback to surface mistakes early.

Notes / judgment calls

  • Enum placement: co-located in the View\Components namespace (next to their consumers) rather than a new src/Enums/ dir, per the CLAUDE.md "don't create new base folders" rule.
  • Pint: the CLAUDE.md references vendor/bin/pint but it isn't installed in this repo — code matches existing sibling style manually. (Worth reconciling the CLAUDE.md / adding pint separately.)

Test plan

  • TDD: 9 new tests (Toolbar + EdgeToolbar), verified RED (5 failed: "InvalidArgumentException not thrown") before implementing, GREEN after. Also corrected an existing test that asserted the buggy align="left".left.
  • vendor/bin/pest --compact205 pass (was 196).
  • No JS/dist changes — no wireflow resync needed.

zachiler and others added 2 commits June 7, 2026 11:43
…O #230)

<x-flow-toolbar> and <x-flow-edge-toolbar> were thin pass-throughs that appended
position/align/show straight onto the Alpine directive with no validation, so an
unrecognized value (e.g. the pre-#22 align="right") silently fell back to
center/default with no error or warning.

They now validate in the constructor against backed enums (ToolbarPosition,
ToolbarAlign, ToolbarShow) and throw InvalidArgumentException naming the valid
values. Shared via a ValidatesEnumProps concern. Scalar-typed props (offset,
edge position, below) are already type-enforced and untouched.

Alpha-breaking: a page passing an invalid value now errors instead of silently
degrading.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Relocate ToolbarPosition/ToolbarAlign/ToolbarShow from View\\Components to a
dedicated Enums namespace — peer to the existing Rules/ and Concerns/ folders,
and where Laravel devs expect value types. Components now import them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zachiler

zachiler commented Jun 7, 2026

Copy link
Copy Markdown
Member Author

Update: enums moved from View\Components to a dedicated src/Enums/ (ArtisanFlow\WireFlow\Enums) — the Laravel-conventional home for value types and a peer to the existing Rules/ / Concerns/ folders. Supersedes the "enum placement" note in the PR description. Suite still green (205).

Adds an alpha-breaking section to the v0.2.1-alpha migration guide covering the
new <x-flow-toolbar> / <x-flow-edge-toolbar> validation — most notably that the
(incorrectly documented) align="left"/"right" now throw; switch to start/end.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zachiler zachiler merged commit 285d297 into dev Jun 7, 2026
@zachiler zachiler deleted the feature/toolbar-enum-validation branch June 7, 2026 22:28
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