fix: 移除项目探索标签数量上限

This commit is contained in:
2026-02-23 20:15:39 +08:00
parent d90236bcf0
commit 16484827c9
3 changed files with 34 additions and 3 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ Shared utilities and infrastructure layers used across the application.
**Purpose**: Input validation and type safety using Zod schemas
- `ProjectInputSchema`: Project data validation (1-10 tags, 1-10 links)
- `ProjectInputSchema`: Project data validation (1+ tags, 1-10 links)
- `WebhookPayloadSchema`: Webhook request validation with API key auth
- `KeywordInputSchema`: Keyword cloud data with visual config
- `ProjectQuerySchema`: Query parameter validation (search, tags, status, pagination)
+32 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
import { AIEventInputSchema } from './validations';
import { AIEventInputSchema, ProjectInputSchema } from './validations';
describe('AIEventInputSchema', () => {
const validEvent = {
@@ -62,3 +62,34 @@ describe('AIEventInputSchema', () => {
})).toThrow();
});
});
describe('ProjectInputSchema', () => {
const baseProjectInput = {
name: 'Agent Park',
description: 'A curated list of practical AI agent tools.',
tags: [{ name: 'ai-agent' }],
links: [{ type: 'GITHUB' as const, url: 'https://github.com/example/repo' }],
};
it('should allow more than 10 tags', () => {
const manyTags = Array.from({ length: 20 }, (_, index) => ({
name: `tag-${index + 1}`,
}));
expect(() =>
ProjectInputSchema.parse({
...baseProjectInput,
tags: manyTags,
})
).not.toThrow();
});
it('should still require at least one tag', () => {
expect(() =>
ProjectInputSchema.parse({
...baseProjectInput,
tags: [],
})
).toThrow();
});
});
+1 -1
View File
@@ -49,7 +49,7 @@ export const ProjectBaseSchema = z.object({
});
export const ProjectInputSchema = ProjectBaseSchema.extend({
tags: z.array(TagSchema).min(1, "At least one tag is required").max(10),
tags: z.array(TagSchema).min(1, "At least one tag is required"),
links: z.array(ExternalLinkSchema).min(1, "At least one link is required").max(10),
});