@@ -31,7 +31,13 @@ class ValidationAspect extends AbstractAspect
3131 */
3232 private static array $ builtinMessages = [
3333 'required ' => ':attribute 为必填项。 ' ,
34- 'email ' => ':attribute 必须是有效的邮箱地址。 ' ,
34+ 'required_if ' => '当 :other 为 :value 时,:attribute 不能为空。 ' ,
35+ 'required_unless ' => '当 :other 不为 :value 时,:attribute 不能为空。 ' ,
36+ 'required_with ' => '当 :values 存在时,:attribute 不能为空。 ' ,
37+ 'required_with_all ' => '当 :values 都存在时,:attribute 不能为空。 ' ,
38+ 'required_without ' => '当 :values 不存在时,:attribute 不能为空。 ' ,
39+ 'required_without_all ' => '当 :values 都不存在时,:attribute 不能为空。 ' ,
40+ 'email ' => ':attribute 必须是有效的电子邮件地址。 ' ,
3541 'phone ' => ':attribute 必须是有效的手机号。 ' ,
3642 'mobile ' => ':attribute 必须是有效的手机号。 ' ,
3743 'integer ' => ':attribute 必须是整数。 ' ,
@@ -278,6 +284,18 @@ private function normalizeRules(array $rules, array $attributes): array
278284 return [$ normalizedRules , $ attributes ];
279285 }
280286
287+ /**
288+ * 获取缓存统计(测试使用)
289+ */
290+ public static function getCacheStats (): array
291+ {
292+ return [
293+ 'rule_cache_size ' => count (self ::$ configCache ),
294+ 'form_request_cache_size ' => count (self ::$ formRequestCache ),
295+ 'fields_cache_size ' => count (self ::$ fieldsCache ),
296+ ];
297+ }
298+
281299 private function getBodyData (ServerRequestInterface $ request , string $ mode ): array
282300 {
283301 return match ($ mode ) {
0 commit comments