refactor: 修改横幅(分类)关于唯一标识验证规则

This commit is contained in:
2025-03-13 09:56:26 +08:00
parent 54a58ffcaf
commit c037561672
2 changed files with 4 additions and 8 deletions

View File

@@ -51,26 +51,22 @@ class SysBannerValidate extends Validate
// 新增场景
public function sceneAdd()
{
return $this->remove('id', 'require|integer');
return $this->remove('id', 'require|integer')->append('unique_label', 'require');
}
// 编辑场景
public function sceneEdit()
{
return $this->remove('language_id', 'require|integer')->append('unique_label', 'empty');
return $this->remove('language_id', 'require|integer')->append('unique_label', 'mustOmit');
}
// 验证是否为空
protected function empty($value, $rule, $data)
protected function mustOmit($value, $rule, $data)
{
if (!isset($data['unique_label'])) {
return true;
}
if (is_null($value) || $value == '') {
return true;
}
return "unique_label必须为空";
}
}