dt3358 2016-02-25 13:13
浏览 97
已采纳

自定义验证消息:Laravel 5.2.15

I have the following code written in Request class under Rules method.

public function rules()
{
    return [
        'Currency' => 'required|max:5|min:2|composite_unique:tblcurrency,CurrencyCode',
        'CurrencyCode' => 'required|max:5|min:1',
    ];
}

This works fine. Only issue is, when the validation fails, I get the following message..

validation.composite_unique

What i tried so far?

After writing the below code, still I am getting the same error string.

public function messages () {
    return [
        'validation.composite_unique'  => 'Duplicate Country and code combination found.',
    ];
}

Question: Can we customize the Validation message to make it look more user friendly?

  • 写回答

2条回答 默认 最新

  • drjltlm156790 2016-02-26 05:24
    关注
    public function messages () {
        return [
            'Currency.composite_unique'  => 'Duplicate Country and code combination found.',
        ];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?