Laravel Validation: check why validator failed

后端 未结 2 1983
长发绾君心
长发绾君心 2021-02-02 00:36

If there a way to check whether or not the validator failed specifically because of the unique rule?

$rules = array(
            \'email_address\' =         


        
2条回答
  •  一个人的身影
    2021-02-02 00:48

    Check for a specific rule within the returned array of failed rules

    if ($validator->fails()) {
    
        $failedRules = $validator->failed();
    
        if(isset($failedRules['email_address']['Unique'])) {
    
        ...
    

提交回复
热议问题