2, 'max' => 100, 'when' => function($data) { return isset($data['name']); }], ['status', 'in', 'range' => ['ACTIVE', 'INACTIVE'], 'when' => function($data) { return isset($data['status']); }], ['timeout', 'integer', 'min' => 1, 'max' => 300, 'when' => function($data) { return isset($data['timeout']); }], ['retry_count', 'integer', 'min' => 0, 'max' => 10, 'when' => function($data) { return isset($data['retry_count']); }], // 业务验证(按顺序执行) [ 'url', new WebhookUrlValidator($this), 'msg' => 'Webhook URL无效', 'when' => function($data) { return isset($data['url']) && !empty($data['url']); } ], [ 'events', new WebhookEventsValidator($this, ['processedEvents']), 'msg' => '事件类型配置无效', 'when' => function($data) { return isset($data['events']); } ], ]; } /** * 默认值 */ public function default(): array { return []; } }