Validator icon indicating copy to clipboard operation
Validator copied to clipboard

Some rules always fail if not set in data

Open jkuchynka opened this issue 1 year ago • 1 comments

If a rule is not present, required, etc... it should not fail if it's not set in data. FYI, this works as expected for some rules, such as string, array, boolean

There are a lot of rules I've found this problem with such as: integer, date and url, and lots more.

I can submit a PR if anyone else sees this as a valid issue.

jkuchynka avatar Feb 06 '24 18:02 jkuchynka

Hi, if you're here because you're using Validator and finding that it doesn't quite match Laravel's behavior, you're not alone.

Luckily, you can use this totally undocumented feature (that doesn't exist in Laravel's validator AFAIK):

nullable|url

Hope it helps somebody else!

rkaw92 avatar Jul 04 '24 14:07 rkaw92