Skip to content

Validate just when input is filled in Laravel nova #4018

@karimpazoki

Description

@karimpazoki
  • Laravel Version: 8.*
  • Nova Version: 3.30.0
  • PHP Version: 8.*

I want to validate unrequited field just when inputs are filled. So the filed should be required if it's empty. I have field like this:

Text::make(__('Slug'), 'slug')->hideFromIndex()
    ->rules('sometimes', 'string', 'min:2', 'max:255'),

But when the filed is empty validation return false and shows error message. I also tried nullable() but still doesn't work. Also I tried it without sometimes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions