67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Validator;
|
|
|
|
use Aether\AetherValidator;
|
|
|
|
class CampusValidator extends AetherValidator
|
|
{
|
|
protected function scenes(): array
|
|
{
|
|
return [
|
|
'create' => [
|
|
'rules' => [
|
|
'name' => 'required|string|max:255',
|
|
'parent_id' => 'required|integer|min:0',
|
|
'level' => 'required|integer|in:1,2,3',
|
|
'province' => 'nullable|string|max:100',
|
|
'city' => 'nullable|string|max:100',
|
|
'address' => 'nullable|string|max:500',
|
|
'contact_phone' => 'nullable|string|max:20',
|
|
'contact_person' => 'nullable|string|max:20',
|
|
'status' => 'nullable|integer|in:0,1',
|
|
],
|
|
'messages' => [
|
|
'name.required' => '校区名称不能为空',
|
|
'parent_id.required' => '父级ID不能为空',
|
|
'level.required' => '层级不能为空',
|
|
'level.in' => '层级只能是1、2、3',
|
|
],
|
|
],
|
|
'update' => [
|
|
'rules' => [
|
|
'id' => 'required|integer|min:1',
|
|
'name' => 'nullable|string|max:255',
|
|
'parent_id' => 'nullable|integer|min:0',
|
|
'level' => 'nullable|integer|in:1,2,3',
|
|
'province' => 'nullable|string|max:100',
|
|
'city' => 'nullable|string|max:100',
|
|
'address' => 'nullable|string|max:500',
|
|
],
|
|
'messages' => [
|
|
'id.required' => '校区ID不能为空',
|
|
'level.in' => '层级只能是1、2、3',
|
|
],
|
|
],
|
|
'query' => [
|
|
'rules' => [
|
|
'id' => 'nullable|integer|min:1',
|
|
'name' => 'nullable|string|max:255',
|
|
'parent_id' => 'nullable|integer|min:0',
|
|
'level' => 'nullable|integer|in:1,2,3',
|
|
'province' => 'nullable|string|max:100',
|
|
'city' => 'nullable|string|max:100',
|
|
'status' => 'nullable|integer|in:0,1',
|
|
'page' => 'nullable|integer|min:1',
|
|
'size' => 'nullable|integer|min:1|max:100',
|
|
],
|
|
'messages' => [
|
|
'level.in' => '层级只能是1、2、3',
|
|
],
|
|
],
|
|
];
|
|
}
|
|
}
|