© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago
Santosh Kumar Das

Issue with required() Function When Using Callback for Validation

PhoneInput::make('phone')
->inputNumberFormat(PhoneInputNumberType::E164)
->strictMode(true)
->required(function (Get $get) {
return is_null(($this->selectedRowId)) && empty($get('email'));
})
->rules([
new UniquePhone(),
'regex:/^(?:\D\d\D){10,}$/',
])
->validationMessages([
'required' => "Either phone or email is required.",
'regex' => "The phone number must contain at least 10 digits.",
])
->separateDialCode(true)
->autoPlaceholder('off')
->countryOrder(['us'])
->initialCountry('us'),


I'm facing an issue with the required() function in the package. It works correctly when I pass a direct false value, but when I use a callback function that returns false under certain conditions, the validation still prompts for a value instead of properly skipping the required check. I’ve confirmed that the callback function returns false as expected, but it doesn't seem to be triggering the required validation logic. Can anyone provide insight or guidance on how to properly use the required() function with a callback to conditionally bypass validation? Any help would be greatly appreciated!
I am sharing the code for reference.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

translate validation.required?
FilamentFFilament / ❓┊help
12mo ago
conditionally required validation
FilamentFFilament / ❓┊help
16mo ago
Required validation for Radio button fails
FilamentFFilament / ❓┊help
3y ago
Required field validation with translatable plugin
FilamentFFilament / ❓┊help
3y ago