['The code field format is invalid.']], 'zh', ); expect($errors['code'][0])->toContain('编码只能使用字母、数字'); }); test('normalizes business shorthand unique in zh', function (): void { $errors = ApiValidationErrors::normalize(['code' => ['unique']], 'zh'); expect($errors['code'][0])->toBe('该内容已存在,请更换后重试。'); }); test('summary joins multiple field errors', function (): void { $normalized = [ 'code' => ['编码格式不正确。'], 'name' => ['名称不能为空。'], ]; expect(ApiValidationErrors::summary($normalized))->toBe('编码格式不正确。;名称不能为空。'); }); test('keeps already localized chinese messages', function (): void { $message = '最小下注额不能小于 0'; $errors = ApiValidationErrors::normalize(['items.0.min_bet_amount' => [$message]], 'zh'); expect($errors['items.0.min_bet_amount'][0])->toBe($message); }); test('normalizes english min length for password in zh', function (): void { $errors = ApiValidationErrors::normalize( ['password' => ['The password field must be at least 8 characters.']], 'zh', ); expect($errors['password'][0])->toBe('密码至少需要 8 个字符。'); }); test('normalizes exact draw items message in zh', function (): void { $errors = ApiValidationErrors::normalize( ['items' => ['items must contain the complete 23 draw prize slots.']], 'zh', ); expect($errors['items'][0])->toContain('23'); }); test('normalizes compact english max for rebate rate in zh', function (): void { $errors = ApiValidationErrors::normalize( ['rebate_rate' => ['rebate rate must not be greater than 1.']], 'zh', ); expect($errors['rebate_rate'][0])->toBe('回水比例不能超过 1(100% 记为 1)。'); }); test('normalizes compact english max for rebate limit in zh', function (): void { $errors = ApiValidationErrors::normalize( ['rebate_limit' => ['rebate limit must not be greater than 1.']], 'zh', ); expect($errors['rebate_limit'][0])->toBe('回水上限不能超过 1(100% 记为 1)。'); });