1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\admin\validate;
- use think\Validate;
- class ManageBlockResource extends Validate
- {
- /**
- * 验证规则
- */
- protected $rule = [
- // 'name' => 'require|format|unique:AuthRule',
- 'block_id' => 'require|number|gt:0',
- 'type' => 'require|in:1,2',
- 'book_id' => 'requireIf:type,1|number|gt:0',
- 'url' => 'requireIf:type,2|url',
- 'free_stime' => 'requireIf:block_id,3|requireIf:block_id,4|dateFormat:Y-m-d H:i:s|lt:free_etime',
- 'free_etime' => 'requireIf:block_id,3|requireIf:block_id,4|dateFormat:Y-m-d H:i:s|gt:free_stime',
- ];
- /**
- * 提示消息
- */
- protected $message = [
- // 'name.format' => 'URL规则只能是小写字母、数字、下划线和/组成'
- 'block_id.require' => '块ID不能为空',
- 'block.number' => '块ID必须为大于零数字',
- 'block.gt' => '块ID必须为大于零数字',
- 'type.require' => '类型不能为空',
- 'type.in' => '类型错误',
- 'book_id.requireIf' => '书籍ID不能为空',
- 'book_id.number' => '书籍ID必须为大于零数字',
- 'book_id.gt' => '书籍ID必须为大于零数字',
- 'url.requireIf' => '跳转URL不能为空',
- 'url.url' => '跳转URL不是有效的URL或IP地址',
- 'free_stime.requireIf' => '限免开始时间错误',
- 'free_stime.dateFormat' => '限免开始时间错误',
- 'free_stime.lt' => '限免开始时间必须小于结束时间',
- 'free_etime.requireIf' => '限免结束时间错误',
- 'free_etime.dateFormat' => '限免结束时间错误',
- 'free_etime.gt' => '限免结束时间必须大于开始时间',
- ];
- /**
- * 验证场景
- */
- protected $scene = [
- 'add' => ['block_id','book_id'],
- 'edit' => [],
- ];
-
- }
|