Closed sinar93 closed 1 year ago
hi
jdate check part date form input date time ex: 1401/07/25 and jdatetime for date and time together
please check parameters request sale_from and sale_to
dd(validator([ 'sale_from' => '1401/07/25 12:20:30', 'sale_to' => '1401-06-31 12:20:30', ],[ 'sale_from' => 'jdatetime:Y/m/d H:i:s', 'sale_to' => 'jdatetime_after:'. request('sale_from') .',Y/m/d H:i:s' ]) ->errors() ->messages());
array:1 [ "sale_to" => array:1 [ 0 => "تاریخ پایان تخفیف باید بعد از باشد." ] ]
Thank you for your reply,
These are the datetime inputs in request: And this is the die dump of validator: Which is incorrect I'm really sorry to bother you, but it always return "تاریخ پایان تخفیف باید بعد از ... باشد" no matter what.
I'm bypassing the problem this way for now:
request()->validate([
'sale_from' => 'jdatetime:Y/m/d H:i:s',
'sale_to' => 'jdatetime:Y/m/d H:i:s'
]);
request()->merge([
'sale_from' => Verta::parse(request('sale_from'))->datetime()->format('Y/m/d H:i:s'),
'sale_to' => Verta::parse(request('sale_to'))->datetime()->format('Y/m/d H:i:s'),
]);
$attributes = request()->validate([
'sale_from' => 'date_format:Y/m/d H:i:s',
'sale_to' => 'date_format:Y/m/d H:i:s|after:sale_from'
]);
(1) Validating Jalali dates in request
(2) Merging Jalali dates with Verta to Gregorian
(3) Checking if dates are in correct order using|after:sale_from
And it works fine for now, I thought it might help.
Best
Hi
I'm trying to do a simple Laravel validation on two date inputs:
sale_from
is the date which sale is started andsale_to
is when sale ends.The problem here is no matter what I enter in date inputs (correct and incorrect) I always get the error message: تاریخ پایان تخفیف باید بعد از sale_from باشد.
I have updated the attributes array in validation translation file:
So it seems weird that it doesn't translate
sale_from
. I think the problem is that it can not read value ofsale_from
. I have also tried jdatetime instead of jdate:I would like to know if you could help me to figure it out. Thanks in advance