ImportField nullable but numeric when not empty

Hello,

I'm looking for a way to make an ImportField nullable but when it is not null it should be numeric.
I have tried this:

  ImportColumn::make('minimum_stock')
      ->label('Minimale voorraad')
      ->ignoreBlankState(true)
      ->example(5)
      ->rules(['numeric']),

But when it is empty it says that it must be numeric. Any suggestions?

Thanks.
Solution
Add ‘ nullable’ to your rules array before ‘numeric
Was this page helpful?