Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Nested after date validation is broken #49955

Closed
BertvanHoekelen opened this issue Feb 2, 2024 · 4 comments
Closed

[BUG] Nested after date validation is broken #49955

BertvanHoekelen opened this issue Feb 2, 2024 · 4 comments
Labels

Comments

@BertvanHoekelen
Copy link
Contributor

Laravel Version

10.43.0

PHP Version

8.3.1

Database Driver & Version

No response

Description

This PR broke the nested date after validation which was working fine in 10.42.0.

Steps To Reproduce

use Illuminate\Support\Facades\Validator;

$validator = Validator::make(
    [
        "dates" => [
            [
                "starts_at" => "2024-02-02 12:00:00",
                "ends_at" => "2024-02-02 14:00:00"
            ]
        ]
    ],
    [
        "dates.*.starts_at" => ["date"],
        "dates.*.ends_at" => ["date", "after:starts_at"]
    ]
);

dd($validator->validate()); // This should just return the array of values but is now Illuminate\Validation\ValidationException: The dates.0.ends_at must be a date after starts at.
@BertvanHoekelen BertvanHoekelen changed the title Nested after date validation is wrong Nested after date validation is broken Feb 2, 2024
@BertvanHoekelen BertvanHoekelen changed the title Nested after date validation is broken [BUG] Nested after date validation is broken Feb 2, 2024
@AV-GregMayes
Copy link

We have been having issues with this on 10.43.0 with non-nested fields, too. The below example works in 10.42.0 but not in 10.43.0

'from_date' => [
    'nullable',
    'date',
    'before_or_equal:to_date',
],
'to_date' => [
    'required',
    'date',
    'after_or_equal:from_date',
],

@MrPunyapal
Copy link
Contributor

We have been having issues with this on 10.43.0 with non-nested fields, too. The below example works in 10.42.0 but not in 10.43.0

'from_date' => [
    'nullable',
    'date',
    'before_or_equal:to_date',
],
'to_date' => [
    'required',
    'date',
    'after_or_equal:from_date',
],

can you give me the case?
because it works for me...

@king724
Copy link

king724 commented Feb 2, 2024

We also had to revert to 10.42 because of the date validation issues that caused a test to fail in our Bitbucket pipeline.

$data = [
     'date_end' => '2021-09-17 13:28:47',
];
public function rules()
    {
        return [
            'date_start' => [
                'nullable',
                'date',
            ],
            'date_end' => [
                'nullable',
                'date',
                'after_or_equal:date_start',
            ],
        ];
    }

And we receive the following error:

{
    "message": "Validation error",
    "errors": {
        "date_end": [
            "The date end must be a date after or equal to date start."
        ]
    }
}

@driesvints
Copy link
Member

We've reverted the original PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants