FavoriteValidate.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\validate;
use think\Validate;
class FavoriteValidate extends Validate
{
protected $rule = [
'id' => 'require',
'title' => 'require|checkTitle',
'table' => 'require',
'url' => 'require|checkUrl',
];
protected $message = [
'id.require' => '收藏内容ID不能为空!',
'title.require' => '收藏内容标题不能为空!',
'table.require' => '收藏内容所在表不能为空!',
'url.require' => '收藏内容链接不能为空!',
'url.checkUrl' => '收藏内容链接格式不正确!'
];
protected $scene = [
];
// 验证url 格式
protected function checkUrl($value, $rule, $data)
{
$url = json_decode(base64_decode($value), true);
if (!empty($url['action'])) {
return true;
}
return '收藏内容链接格式不正确!';
}
// 验证url 格式
protected function checkTitle($value, $rule, $data)
{
if (base64_decode($value)!==false) {
return true;
}
return '收藏内容标题格式不正确!';
}
}