FilamentF
Filament3y ago
jeph

Validation didn't work

It's a simple ->gt() validation but I can't seem to make it work.. I can't figure out why. Please help. thanks.

Fieldset::make('Domain Length')
                                ->schema([
                                    TextInput::make('min')
                                        ->numeric()
                                        ->live(),
                                    TextInput::make('max')
                                        ->hintIcon('heroicon-o-information-circle','Length excluding the extension.')
                                        ->numeric()
                                        ->gt('min')
                                        ->live(),
                                ])->columnSpan(2),


I also tried custome rules but it still wont work.

TextInput::make('max')
                                        ->hintIcon('heroicon-o-information-circle','Length excluding the extension.')
                                        ->numeric()
                                        ->rules([
                                          function () {
                                              return function (GET $get, $value, Closure $fail) {
                                                  if ($value > $get('min') {
                                                      $fail('The :attribute is invalid.');
                                                  }
                                              };
                                          },
                                      ])
                                        ->live(),
Was this page helpful?