Skip to content

Before & After: Should not throw an exception if the value is empty. #154

@mahyarkhanbabai

Description

@mahyarkhanbabai

Hey, I have a validator rule like this:

$validator->make($_POST, 'dateOfBirth'=>'date:Y/m/d|before:today' );

As you can see, the date field is not required, it is optional, but if someone wants to enter it, it must be in the given format and before today. The problem is when the user leaves the field empty, we get an error that says:
... Argument #1 ($date) must be of type string, null given, called in ...

So you get the point. I am pretty sure we should leave checking the value for empty/null values for the "required" rule and return true if the field is empty, in "before and after" rules.

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