*/ public function rules() { return [ 'sun_sign' => ['max:255'], 'moon_sign' => ['max:255'], 'time_of_birth' => ['max:10'], 'city_of_birth' => ['max:20'], ]; } public function messages() { return [ 'sun_sign.max' => translate('Max 255 characters'), 'moon_sign.max' => translate('Max 255 characters'), 'time_of_birth.max' => translate('Max 10 characters'), 'city_of_birth.max' => translate('Max 20 characters'), ]; } /** * Get the error messages for the defined validation rules.* * @return array */ public function failedValidation(Validator $validator) { // dd($this->expectsJson()); if ($this->expectsJson()) { throw new HttpResponseException(response()->json([ 'message' => $validator->errors()->all(), 'result' => false ], 422)); } else { throw (new ValidationException($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); } } }