fix: harden match live validation

This commit is contained in:
hajimi
2026-06-21 12:04:01 +08:00
parent 80e0e6a8a6
commit cd9530686c
2 changed files with 95 additions and 5 deletions
@@ -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;
}
}