在我所在的服務器沒有啓用FILE_INFO後,我需要一種快速驗證單詞文檔的方法。laravel - 將消息添加到新註冊的驗證
Validator::register('word', function($attribute, $value, $parameters)
{
$valid_type = array(
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
);
$valid_extentions = array(
'doc',
'docx'
);
if(! is_array($value))
{
return false;
}
if(! isset($value['type']))
{
return false;
}
if(! in_array(strtolower($value['type']), $valid_type))
{
return false;
}
if(! in_array(strtolower(substr(strrchr($value['name'], '.') , 1)), $valid_extentions))
{
return false;
}
return true;
});
我知道這不是防彈但將盡現(添加建議,如果您有任何),但我怎麼添加一個消息這是目前它返回
validation.word
什麼想法?
這是偉大的!你知道我需要放置*自定義驗證規則*爲了成爲全球嗎?我使用Validator :: extend() – 2013-09-05 08:28:04