feat(toolbar): validate enum props, throw on invalid values#25
Merged
Conversation
…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>
Member
Author
|
Update: enums moved from |
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>
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.
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 throwInvalidArgumentExceptionnaming the valid values:position→top/bottom/left/rightalign→center/start/endshow→selected/alwaysNew
ToolbarPosition/ToolbarAlign/ToolbarShowenums + a sharedValidatesEnumPropsconcern. Scalar-typed props (offset, edgeposition,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
View\Componentsnamespace (next to their consumers) rather than a newsrc/Enums/dir, per the CLAUDE.md "don't create new base folders" rule.vendor/bin/pintbut it isn't installed in this repo — code matches existing sibling style manually. (Worth reconciling the CLAUDE.md / adding pint separately.)Test plan
align="left"→.left.vendor/bin/pest --compact— 205 pass (was 196).