48 lines
1.9 KiB
PHP
48 lines
1.9 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace plugin\produce\app\validate;
|
||
|
|
|
||
|
|
use core\base\BaseValidate;
|
||
|
|
|
||
|
|
class SpecificRuleValidate extends BaseValidate
|
||
|
|
{
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'rule_name' => ['required', 'max:255'],
|
||
|
|
'rule_pattern' => ['required'],
|
||
|
|
'rule_type' => ['required', 'integer'],
|
||
|
|
'apply_mode' => ['required', 'in:order,machine,both'],
|
||
|
|
'match_field' => ['required', 'in:order_no,process_order_no,product_code,user_code'],
|
||
|
|
'is_enabled' => ['nullable', 'integer', 'in:0,1'],
|
||
|
|
'step_ids' => ['nullable'],
|
||
|
|
'sort' => ['nullable', 'integer', 'min:0'],
|
||
|
|
'remark' => ['nullable', 'max:65535'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
protected array $message = [
|
||
|
|
'rule_name.required' => '规则名称不能为空',
|
||
|
|
'rule_name.max' => '规则名称不能超过255个字符',
|
||
|
|
'rule_pattern.required' => '规则表达式不能为空',
|
||
|
|
'rule_type.required' => '规则类型不能为空',
|
||
|
|
'rule_type.integer' => '规则类型格式不正确',
|
||
|
|
'apply_mode.required' => '适用模式不能为空',
|
||
|
|
'apply_mode.in' => '适用模式值不正确',
|
||
|
|
'match_field.required' => '匹配字段不能为空',
|
||
|
|
'match_field.in' => '匹配字段值不正确',
|
||
|
|
'is_enabled.integer' => '启用状态格式不正确',
|
||
|
|
'is_enabled.in' => '启用状态值不正确',
|
||
|
|
'sort.integer' => '排序必须为整数',
|
||
|
|
'sort.min' => '排序不能小于0',
|
||
|
|
'remark.max' => '备注内容过长',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected array $scene = [
|
||
|
|
'store' => ['rule_name', 'rule_pattern', 'rule_type', 'apply_mode', 'match_field', 'is_enabled', 'step_ids', 'sort', 'remark'],
|
||
|
|
'update' => ['rule_name', 'rule_pattern', 'rule_type', 'apply_mode', 'match_field', 'is_enabled', 'step_ids', 'sort', 'remark'],
|
||
|
|
];
|
||
|
|
}
|