Validation 拉雷维尔——”;其他";占位符不接受验证消息中的友好名称

Validation 拉雷维尔——”;其他";占位符不接受验证消息中的友好名称,validation,placeholder,laravel,Validation,Placeholder,Laravel,在拉雷维尔 我在项目中使用自定义验证来检查mininum area的值是否小于maximum area。刚刚在验证器库中创建了验证 public function validate_less_than($attribute, $value, $parameters) { $other_value = $this->attributes[$parameters[0]]; if(!empty($value) && !empty($

在拉雷维尔

我在项目中使用自定义验证来检查mininum area的值是否小于maximum area。刚刚在验证器库中创建了验证

public function validate_less_than($attribute, $value, $parameters)
{
            $other_value = $this->attributes[$parameters[0]];
            if(!empty($value) && !empty($other_value))
                return $value <= $other_value;
            else    
                return true;    
}
并在验证程序库中添加了替换占位符函数,以替换:其他占位符

protected function replace_less_than($message, $attribute, $rule, $parameters)
    {
                return str_replace(':other', $parameters[0], $message);
    }

我的字段名类似于“min_area”、“max_area”,因此我不希望在验证消息中使用此字段名,因此我在语言文件中为这些字段添加了友好的名称。但是“:other”占位符不采用验证语言文件中指定的友好名称。是否只允许“:attribute”placeholder?

它在validator.php中的第856行(当前版本3.2.12)附近硬编码

你可以从你的替代者那里运行它

受保护函数替换小于($message、$attribute、$rule、$parameters)
{
返回str_replace(':other',$this->attribute($parameters[0]),$message);
}
请注意
$this->attribute()

protected function replace_less_than($message, $attribute, $rule, $parameters)
    {
                return str_replace(':other', $parameters[0], $message);
    }