DWQA QuestionsCategory: LaravelHow to write custom validation message in laravel5.2 in request file ?
asked 6 years ago

Solution :
Example :

/*
     * Set validation Message
     * 
     * @param
     * @return array
     */
    
    public function messages() {
        return [  
            ‘parentCat.required’ => ‘Please select at least one Parent Category.’,
            ‘subCat.required’ => ‘Please select at least one Sub Category.’,
            ‘promotions_type.required’ => ‘Promotion Type field is required.’,
            ‘discount.required’ => ‘Get (Y) field is required.’,
            ‘start_date.required’ => ‘Start date field is required.’,
            ‘end_date.required’ => ‘End date field is required.’,
            ‘promo_code.alpha_num’ => ‘Invalid character in Promocode !!’,
            ‘promo_code.size’ => ‘Promocode must be 8 character long.’,
            ‘promo_code.required’ => ‘Promocode field is required.’,
            ‘min_qty.required’ => ‘Buy (X) field is required.’
        ];
    }