fix: harden match live validation
This commit is contained in:
@@ -11,8 +11,8 @@ class MatchLiveValidate extends BaseValidate
|
||||
protected $rule = [
|
||||
'id' => 'require|integer|gt:0|checkLive',
|
||||
'match_id' => 'require|integer|gt:0|checkMatch',
|
||||
'title' => 'require|length:1,255',
|
||||
'source_url' => 'require|max:500',
|
||||
'title' => 'require|checkTrimmedTitle',
|
||||
'source_url' => 'require|checkTrimmedSourceUrl',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
@@ -66,4 +66,28 @@ class MatchLiveValidate extends BaseValidate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkTrimmedTitle($value)
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
if ($value === '') {
|
||||
return '直播标题不能为空';
|
||||
}
|
||||
if (mb_strlen($value) > 255) {
|
||||
return '直播标题长度须在1-255位字符';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkTrimmedSourceUrl($value)
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
if ($value === '') {
|
||||
return '源地址不能为空';
|
||||
}
|
||||
if (mb_strlen($value) > 500) {
|
||||
return '源地址长度不能超过500位字符';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user