Skip to main content
Copy for LLM

Strict Validation

Every WireKit component with a prop enum (<x-wirekit::button intent="primary">, <x-wirekit::alert intent="info">, <x-wirekit::hero size="lg">, …) routes invalid values through a single decision point: the StrictnessGate. The gate decides whether to throw, log, and which value to render when a developer typo lands in production code.

The decision depends on the runtime context. That is intentional — a typo in a Pest test should fail fast and visibly; the same typo on a live HTTP request should not 500 the whole page over a cosmetic glitch. This page documents the full matrix so you can decide which mode fits each environment.

The decision matrix

Two configuration knobs interact with the runtime context:

Knob Default What it does
wirekit.validation.strict null (auto-detect from APP_DEBUG) When null, the gate is strict if APP_DEBUG=true, lenient otherwise. Set explicitly to true or false to override the auto-detect.
wirekit.validation.throw_on_invalid null (context: console throws, HTTP degrades) Three states, not two. null defers to the runtime context. true forces the throw even in an HTTP request — useful for a staging environment that should fail loudly. false forces degradation even in console and Pest, which switches off the fail-fast the row below promises.

The resulting behavior:

Runtime context strict=true (or APP_DEBUG=true) strict=false (or APP_DEBUG=false)
HTTP request log ERROR + render fallback log WARNING + render fallback
CLI / Pest / artisan tinker throw InvalidArgumentException log WARNING + render fallback
throw_on_invalid=true (any context) throw InvalidArgumentException log WARNING + render fallback
throw_on_invalid=false (any context) log ERROR + render fallback log WARNING + render fallback

The gate constructs an InvalidArgumentException. When the value came from a Blade template, Laravel's view engine wraps it in an Illuminate\View\ViewException before it reaches your code — the message survives the wrap, so that is the class a toThrow assertion names. The worked example below does.

throw_on_invalid decides how the gate fails, not whether it engages. Prop validation only throws while the gate is strict — under strict=false an invalid value logs a WARNING and renders the fallback whatever throw_on_invalid says. The knob is unconditional for one neighboring case: an unknown icon name reads it directly, so throw_on_invalid=true throws there in an HTTP request too.

Fallback semantics: when the gate renders a fallback value, it renders the prop's default, the value the component draws when the prop is left out, wherever the prop's allowed values hold it. A typo then draws what leaving the prop out draws: for <x-wirekit::button surface="weird-typo"> the fallback is surface="filled", and <x-wirekit::avatar size="huge"> draws the md avatar. A default set in config/wirekit.php counts as the default. A prop whose default is not one of its allowed values, such as one that defaults to nothing, falls back to the first allowed value. Each component can override the fallback per prop; the override surfaces in the same log line.

Why the split exists

A naive "throw on any typo" policy looks safe in isolation but creates a worse production failure mode: one cosmetic prop typo (a developer wrote surface="outlne" instead of surface="outline") takes down the entire Blade view with a 500 error. The page that should have rendered with a slightly-wrong button now renders nothing at all.

The matrix above resolves the trade-off:

  • In a Pest test, the throw surfaces the typo at the assertion that should have caught it. No silent log line; no rendered fallback the test then accidentally validates.
  • In php artisan tinker, the throw matches what a developer would expect from a debugger — you typed the wrong thing, you get a stack trace.
  • In a live HTTP dev request (APP_DEBUG=true), the page renders with the fallback so you can see the rest of the layout, and the local.ERROR: WireKit [...] line tells you exactly what went wrong.
  • In production, the log line drops to WARNING (less noisy) but the fallback still keeps the page alive.

Spotting silent typos in logs

Two options:

Option 1 — let wirekit:doctor scan the log for you. The doctor's environment-tier checks include an optional silent-typo log scan that walks the files of the single and daily channels, storage/logs/laravel*.log unless their path says otherwise, for the WireKit [...] ERROR / WARNING lines emitted by StrictnessGate. A WARN with example lines surfaces every typo that fired inside the scan window:

# 1. The environment-tier checks include the log scan.
php artisan wirekit:doctor --tier=environment

The scan degrades safely at every failure mode — missing log file, custom log channel (Slack / Papertrail / Sentry), log-level filtering below WARNING — it surfaces an info line explaining the skip and never blocks the doctor's exit code. Disable entirely by setting wirekit.doctor.scan_logs to false (or WIREKIT_DOCTOR_SCAN_LOGS=false in .env) when your app doesn't write file-based logs.

The window is the last 24 hours by default, judged by each line's timestamp. Older WireKit lines are counted in the message but do not turn the check yellow, so a typo you fixed drops out once its last line is older than the window. Set wirekit.doctor.scan_logs_window_hours (or WIREKIT_DOCTOR_SCAN_LOGS_WINDOW_HOURS in .env) to widen or narrow it; 0 reads the whole file.

Option 2 — grep the log directly. Lenient mode logs at WARNING level; strict-HTTP logs at ERROR. Either way the lines look the same:

# 1. From your project root, scan today's log for any WireKit fallback events.
grep 'WireKit \[' storage/logs/laravel.log

# 2. Narrow to one component if you suspect a specific surface.
grep 'WireKit \[button\]' storage/logs/laravel.log

# 3. Tail the log live while you click through the app to catch typos as they fire.
tail -f storage/logs/laravel.log | grep --line-buffered 'WireKit \['

A typical line looks like:

[2026-05-28 06:54:53] local.ERROR: WireKit [button]: Invalid surface "outlne". Allowed: filled, outline, soft, ghost, link. Did you mean: outline? Falling back to "filled".

The Falling back to "..." suffix is the source of truth for what the page actually rendered.

Each rejection is logged once per request for its component, prop and value, so a value that renders in a loop leaves one line rather than one per row. The value is quoted as a single line: a control character such as a line break appears as �, and a value longer than 64 characters is cut and ends in …. A prop bound to data your application did not write, such as :intent="$ticket->priority", cannot start a log line of its own that way.

A form control given a list where it takes one value logs the same way. old('email') returns a list when a request sent email[], and a rule such as string sends the reader back to the form with it, so a line such as WireKit [input]: Invalid value "array". Expected one value, not a list. comes from a request rather than from a template. The control renders without the value, and the page still shows its validation errors.

Opting into strict mode for staging

Staging environments typically run with APP_DEBUG=false to mirror production, which puts the gate into lenient mode. If you would rather fail loudly on a typo before it reaches end users, flip the two knobs explicitly in your staging .env:

# 1. Force the gate into strict mode regardless of APP_DEBUG.
WIREKIT_STRICT_VALIDATION=true

# 2. Force a throw on every invalid value — no fallback, full stack trace.
WIREKIT_THROW_ON_INVALID=true

Add the corresponding config wiring to config/wirekit.php:

<?php

use Pushery\WireKit\Support\EnvValue;

// 1. The 'validation' block lives at the top level of the wirekit config.
return [
    // …
    'validation' => [
        // 2. null = auto-detect from APP_DEBUG. true/false = explicit override.
        'strict' => EnvValue::get('WIREKIT_STRICT_VALIDATION'),
        // 3. null = defer to the context (console throws, HTTP degrades). true = throw
        //    even in HTTP, so an invalid prop 500s the request. false = never throw,
        //    including in Pest — leave this one unset unless you mean that.
        'throw_on_invalid' => EnvValue::get('WIREKIT_THROW_ON_INVALID'),
    ],
    // …
];

EnvValue::get() reads a variable the way env() does, with one difference: a line with nothing after the =, such as WIREKIT_THROW_ON_INVALID=, counts as unset. The setting keeps its default, exactly as if the line were not there, instead of arriving as an empty string.

Both settings are read as switches. on, yes and 1 mean true and off, no and 0 mean false, in upper or lower case, as true and false do. A word that means neither leaves the setting unset, so the default decides.

Be careful with throw_on_invalid=true in production — every invalid prop value will 500 the request that triggered it. The setting is useful in CI's smoke-test job and dangerous in front of real visitors. You must leave it false in production unless you have a deliberate fail-loudly policy.

Testing strict mode in Pest

CLI context already triggers the throw branch when strict mode is active. A typical regression test reads:

<?php

// 1. Pest test asserting an invalid prop value throws under strict mode.
use Illuminate\Support\Facades\Blade;
use Illuminate\View\ViewException;

it('rejects unknown surface values on <x-wirekit::button>', function () {
    // 2. Force strict mode explicitly so the test is independent of APP_DEBUG.
    config()->set('wirekit.validation.strict', true);

    // 3. The render call throws because 'outlne' is not in the surface enum. Blade wraps
    //    the gate's InvalidArgumentException in a ViewException, and the message survives
    //    the wrap — so assert on the wrapper class and match on the message.
    expect(fn () => Blade::render('<x-wirekit::button surface="outlne">x</x-wirekit::button>'))
        ->toThrow(ViewException::class, 'Invalid surface "outlne"');
});

The value you assert on must be one the component really rejects. surface="outlined" looks like the obvious typo and is not one — button declares it as an alias for outline, so it renders happily and the assertion above fails with "nothing was thrown". Pick something genuinely outside the enum; the dropped-letter outlne is.

The exception message carries a Levenshtein-ranked Did-you-mean hint — Did you mean: outline? — so the failing assertion already points at the likely correct value.

How intent and surface interact under the gate

Components like <x-wirekit::button> and <x-wirekit::badge> carry two orthogonal enums (intent + surface). The gate runs each prop independently — an invalid intent falls back to primary, an invalid surface falls back to filled, and a value that lands outside both enums logs two separate lines. See Variants & Intents for the full prop-value catalog.

Asking the gate instead of reading its log

The gate's warnings are written for a developer reading a log. The questions behind them are also available as plain predicates you can assert on in your own test suite — useful when you want a build to fail rather than a line to appear.

Each returns an answer and nothing else: no logging, and no app.debug gate. That matters, because the warnings themselves return early outside debug mode, so in production the signal does not exist at all and no test can reach it.

use Pushery\WireKit\Support\StrictnessGate;

// Attribute names that are neither declared props nor legitimate HTML passthrough.
StrictnessGate::unknownPropNames($attributes, $declaredProps);   // => ['varaint']

// Scope directives this component will discard, because it sets its own on the
// same element and HTML keeps the first of two identical attributes.
StrictnessGate::discardedScopeDirectives('dropdown', ['x-data' => '{ open: false }']);
// => ['x-data']

// Attributes only a form control takes, which this component gives to none of its own.
StrictnessGate::controlAttributesWithoutAControl('accordion.item', ['disabled' => true]);
// => ['disabled']

// A binding this component hands to no field, named with its property.
StrictnessGate::controlAttributesWithoutAControl('collapsible', ['wire:model.live' => 'open']);
// => ['wire:model.live="open"']

What passes as HTML: every global attribute of the HTML standard (id, class, popover, the microdata attributes and the rest), the attributes a form control, link, image or table cell takes, aria-*, data-*, the framework prefixes (wire:, x-, @, :), and the event-handler attributes spelled the way HTML spells them, in lowercase (onclick, oninput). A few props begin with the same two letters, so an on name in any other case is read as a prop: onLable on toggle-button is reported as a typo of onLabel. A lowercase name one letter away from a declared prop is reported too, such as onse beside reveal's once.

discardedScopeDirectives() reads the component's own Blade template and asks whether it sets the directive unconditionally — a component that only sets x-data inside a condition does not always discard yours, and answering otherwise would report a collision that does not happen. That distinction is why asking WireKit is better than re-deriving the answer from the templates yourself.

disabled, required and readonly pass as HTML, but they do something only on a form control. On a component that gives them to none of its own, they land on the element around its control and do nothing: the button of an accordion item stays enabled. The same goes for an attribute Livewire sets while a request runs, wire:loading.attr="disabled". The gate logs a warning for either while debugging, and controlAttributesWithoutAControl() gives the same answer. To disable every control inside a component, put the attribute on a <fieldset> around it:

<fieldset wire:loading.attr="disabled">
    <x-wirekit::multi-select name="tags" label="Tags" :options="$tags" />
</fieldset>

autofocus is reported the same way where it reaches nothing that can take the focus, such as the element around a collapsible's button.

readonly acts only on a field that takes text, a date, a time or a number. A checkbox, a radio, a range and a color field ignore it, so a toggle, a checkbox, a radio, a slider and a color picker report it too, and stay operable. disabled is what stops a change there.

wire:model is reported on a component that binds no value with it, such as a collapsible. Livewire binds it to the element it is written on, and on the element around a collapsible's button no field shows the property's value. The warning names the binding with its property, so the call site can be found. The form components take it, and so do a modal, a drawer and an alert dialog, whose wire:model opens and closes them. A component that binds it in one mode reports it in a mode where it binds nothing, such as a data table without selectable or a readonly rating, and names what is missing. A pricing table without intervals reports a tier given prices the same way: nothing switches the amounts there, and the tier shows its first. A table without alpine-sort reports a head with sortable and column, which reads as unsorted there.

A discarded x-data is not a degradation, it is a disconnection. Your scope never comes into existence, so everything written against it — an x-init beside it, a @click inside it — silently resolves against the component's own data. Wrap the component in your own element, or use the API the component already exposes.

Texts

A prop that takes a text, such as a label, a hint or a title, reports a list, a collection or an object without a text of its own as an invalid prop, and the component renders as it does without the prop. A translation key that names a group of lines rather than one line is the usual way to get there: __('checkout.address') returns every line under that key as a list, and :label="__('checkout.address')" on an input reports it. An object that writes itself as text, such as an HtmlString or a date, is a text.

The author of a message and of a message group takes a list as well, a record with a name and a picture, and so does the badge label of an app rail item, a list of sentences.

Values from a list

A prop that takes one value from a fixed list, such as the size of a button, the intent of a badge or the orientation of a field, reports a list, a collection or an object without a text of its own as an invalid prop, and the component renders with the prop's default. A setting read from a file that holds several values is the usual way to get there: :size="config('shop.button_sizes')" hands over the whole list.

Each component is read on its own terms, since one name can take one value on one component and something else on another: max is a width on a container and a day on a calendar, and columns is one number on the panel of a usage meter and the list of columns of a data table.

A prop that takes a single value without a fixed list, such as the scope every component takes or the srcset of an image, reports a list the same way and renders without it. An object passes there: the timezone of a date separator takes a DateTimeZone, and the datetime of a timeline item a date.

Numbers

A prop that takes a number reports a text that holds none as an invalid prop: max="1OO" on a slider, step="0,5" on a number input or delay-show="soon" on a tooltip. The component renders with the prop's default, or, for the few props that take the number a text starts with, such as the search-debounce of a data table, with that number, so 300ms waits 300 milliseconds. An empty text passes without a report, and so does a number written as text, max="100".

The value of a field is not checked, for the reason the value of a date field is not: the value of a slider and an image compare, and the min-value and max-value of a range slider, hold what the reader sent after a failed validation.

Lists

A prop that takes a list reports a text, a number or a switch as an invalid prop, and reads it as an empty list, so the component renders with nothing in it: options="Red,Green" on a select written without its colon, say, or a JSON column read without its array cast. An empty text is an empty list without a report.

Some list props take a text as well: the name of a message's author, the comma-separated value of a multi-select or a tags input, and a single item written as text, such as countries="DE" on a phone field.

Fields of the items in a list

A field of an item that takes one word from a fixed list is checked the way a prop is, and the report names the item: a data table column whose cellType is money is reported as Invalid columns[3].cellType "money", and a lightbox item whose type is Embed as Invalid items[1].type "Embed". Where the report does not throw, the item renders with the field's fallback, a text cell and an image here. An empty field holds no value and passes without a report.

A field that switches something on or off, such as the disabled of a select option or the allDay of an event calendar event, reads the words a switch prop reads, so the text false from a JSON column is off.

Switches

A prop that is a switch reads the words that name one, true, false, 1, 0, on, off, yes and no in any case, and the prop's own name, as HTML writes disabled="disabled". Any other text is reported as an invalid prop: dismissible="flase" on a modal, say, a typing error that leaves the dialog dismissible. The component renders with the switch on. An empty text is off without a report.

A few switches take a word of their own as well, and report any other word, their own name included, with the words they take: responsive for the wrap of a row, words for the wrap of a table header, top for the rule of a shell bar and tooltip for the truncate of a text.

Dates and times

A date, a time or a moment written as text that a component cannot read is reported as an invalid prop, and then counts as none: a bound such as min or max on a calendar or a picker, an entry of unavailable that names neither a day nor a time, the start or the end of an event calendar's event, and the date of a countdown, a review, a message or a date separator. An empty text, white space and the zero date 0000-00-00 that older MySQL schemas write are no date and pass without a report, as null and false do.

The value of a date or time field is not checked. After a failed validation it holds what the reader sent, and a field reads a value that is no date as empty.

See Also

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store