Fix new date input timezone issue (#88)

* fix timezone issue on new date input

* date range validation error
This commit is contained in:
Chirag Chhatrala
2023-02-13 14:20:19 +05:30
committed by GitHub
parent 7b5968401b
commit 9137282eba
2 changed files with 52 additions and 7 deletions

View File

@@ -121,6 +121,24 @@ class AnswerFormRequest extends FormRequest
return $fields;
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
$messages = [];
foreach ($this->form->properties as $property) {
if($property['type'] == 'date' && isset($property['date_range']) && $property['date_range']){
$messages[$property['id'].'.0.required_with'] = "From date is required";
$messages[$property['id'].'.1.required_with'] = "To date is required";
$messages[$property['id'].'.0.before_or_equal'] = "From date must be before or equal To date";
}
}
return $messages;
}
/**
* Return validation rules for a given form property
* @param $property
@@ -160,6 +178,8 @@ class AnswerFormRequest extends FormRequest
case 'date':
if (isset($property['date_range']) && $property['date_range']) {
$this->requestRules[$property['id'].'.*'] = $this->getRulesForDate($property);
$this->requestRules[$property['id'].'.0'] = ['required_with:'.$property['id'].'.1', 'before_or_equal:'.$property['id'].'.1'];
$this->requestRules[$property['id'].'.1'] = ['required_with:'.$property['id'].'.0'];
return ['array', 'min:2'];
}
return $this->getRulesForDate($property);