实际上,我试图创建规则对象,它能够验证图像数组中的每个图像类型,不仅足够,而且,我必须在规则对象的覆盖消息功能中显示自定义消息。
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class ImagesArray implements Rule
{
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
return [$attribute => 'mimes:jpeg,jpg,png' ];
here i need to validate these file types.
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'The validation error message.';
here, I need to show my custom messgae.
}
}