© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
Hemith

Assert for custom form validation values

An example would be from the filament docs:
TextInput::make('slug')->rules([
    function () {
        return function (string $attribute, $value, Closure $fail) {
            if ($value === 'foo') {
                $fail('The :attribute is invalid.');
            }
        };
    },
])
TextInput::make('slug')->rules([
    function () {
        return function (string $attribute, $value, Closure $fail) {
            if ($value === 'foo') {
                $fail('The :attribute is invalid.');
            }
        };
    },
])


How can I assert for this particular validation when testing forms? I'm not sure what name to use.
Solution
Got it. I could output the errors with
$component->errors();
$component->errors();


I can then check the validation error I want from there.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Custom View Form Validation
FilamentFFilament / ❓┊help
2y ago
Form validation
FilamentFFilament / ❓┊help
3y ago
Validation for custom page
FilamentFFilament / ❓┊help
2y ago
Custom Edit Form Input Values Not Populating Input values
FilamentFFilament / ❓┊help
3y ago