Files

45 lines
1.3 KiB
PHP

<?php
/*
* @Author: YwxApp <ywx@ywxapp.cn>
* @Date: 2026-04-29 02:32:33
* @LastEditors: YwxApp <ywx@ywxapp.cn>
* @LastEditTime: 2026-07-23 00:00:00
* @Description: 友情链接验证器
* @FilePath: \ywxapp_dev\app\backend\validate\Links.php
* @CustomString: Copyright (c) 2026 YwxApp
*/
declare (strict_types = 1);
namespace app\backend\validate;
use think\Validate;
class Links extends Validate
{
protected $rule = [
'title' => 'require|max:255',
'url' => 'require|url|max:255',
'logo' => 'max:255',
'description' => 'max:500',
'sort' => 'integer',
'status' => 'in:0,1',
];
protected $message = [
'title.require' => '网站标题不能为空',
'title.max' => '网站标题过长',
'url.require' => '链接地址不能为空',
'url.url' => '链接地址格式不正确',
'url.max' => '链接地址过长',
'logo.max' => 'Logo 地址过长',
'description.max' => '网站描述过长',
'sort.integer' => '排序必须为整数',
'status.in' => '状态值非法',
];
// 仅保存/完整编辑时校验标题与链接;状态开关不需要
protected $scene = [
'save' => ['title', 'url', 'logo', 'description', 'sort', 'status'],
];
}