Q:

Form Request, how to add additional error messages after performing a validation using an if- condition?

Adding error messages inside form requests using certain conditions.
I am making a form request in order to handle my validations. In my form, I have a couple of fields but the important ones are "Month" "Day" or "Year" pulldown. They are all set to required, and if one of them invalidates the required rule, the form request would handle it by creating another error inside the $validator.
The logic goes something like this.
If (month = fail || day = fail || year = fail) {
   $validator->errors()->add('date', 'please fill out the whole date)
}

I'd like to do this somewhere in my form request after the validation.
This is my rules for the form request field.
public function rules()
    {
        return [
            'name' => 'nullable',
            'sex' => 'nullable',
            'phone_number' => 'nullable',
            'email' => 'nullable',
            'month' => 'bail|required',
            'day' => 'bail|required',
            'year' => 'bail|required',
        ];
    }

And on my view (twig template) under the select fields of month, day, year, I have this to supposedly show my error message:
{{errors.first('date')}}

So far I don't know how to write the condition and add a custom error message.
Edit: I found an answer, but I'm not sure if this is good practice. Maybe someone can find a better answer than this.
protected function failedValidation(Validator $validator) {

        if (array_key_exists('month', $validator->failed()) || 
            array_key_exists('day', $validator->failed()) ||
            array_key_exists('year', $validator->failed()) ) {
                $validator->getMessageBag()->add('date', 'sample error message');
            }
}

A:

I think it would be best to use an After Validation Hook. 
You would typically add this to your Form Request. 
/**
* Configure the validator instance.
*
* @param  \Illuminate\Validation\Validator  $validator
* @return void
*/
public function withValidator($validator)
{
    $validator->after(function ($validator) {
        if(
            $validator->errors()->has('month')
            || $validator->errors()->has('day')
            || $validator->errors()->has('year')
        ) {
            $validator->errors()->add('date', 'Please fill out the whole date!');
        }
    });
}

You can check the documentation for more information. 

