feat(figue): integrate @standard-schema/spec to replace zod#9
Conversation
aced400 to
b235be0
Compare
b235be0 to
f1d9a83
Compare
f1d9a83 to
b0266ed
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR integrates @standard-schema/spec to replace Zod as the schema validation library, enabling support for any standard-schema-compliant validation library while maintaining type safety.
Key changes:
- Replaces Zod-specific schema validation with standard-schema-compliant validation
- Updates type definitions to use
StandardSchemaV1instead ofZodType - Implements custom validation logic to handle both synchronous validation and nested configurations
Reviewed Changes
Copilot reviewed 21 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/figue.types.ts | Updates type definitions to use StandardSchemaV1 and adds new ConfigIssue type |
| src/figue.ts | Replaces Zod validation with standard-schema validation and implements custom validation logic |
| src/figue.errors.ts | Updates error handling to work with ConfigIssue instead of ZodIssue |
| package.json | Removes Zod dependency and adds @standard-schema/spec |
| src/figue.test.ts | Adds tests demonstrating usage with both Zod and Valibot |
Comments suppressed due to low confidence (1)
package.json:67
- Zod version 4.0.10 does not exist. The latest stable version of Zod is 3.x.x. This should be updated to a valid version like "^3.23.8".
"zod": "^4.0.10"
| } | ||
|
|
||
| if (validation.issues) { | ||
| return { issues: validation.issues.map(issue => ({ ...issue, path: currentPath, definition })) }; |
There was a problem hiding this comment.
The spread operator may overwrite the path property from the original issue. Consider preserving the original issue path or merging paths appropriately to maintain validation context.
| return { issues: validation.issues.map(issue => ({ ...issue, path: currentPath, definition })) }; | |
| return { | |
| issues: validation.issues.map(issue => ({ | |
| ...issue, | |
| path: issue.path ? [...issue.path, ...currentPath] : currentPath, | |
| definition | |
| })) | |
| }; |
| definition: ConfigDefinitionElement; | ||
| value: unknown; | ||
| currentPath: string[]; | ||
| }): { config?: unknown; issues: ConfigIssue[] } { |
There was a problem hiding this comment.
The code assumes all schemas have a '~standard' property but doesn't handle cases where this might be missing. Consider adding a check or providing a more descriptive error message when the schema is not standard-schema compliant.
| }): { config?: unknown; issues: ConfigIssue[] } { | |
| }): { config?: unknown; issues: ConfigIssue[] } { | |
| if (!definition.schema || !definition.schema['~standard']) { | |
| return { | |
| issues: [ | |
| { | |
| path: currentPath, | |
| message: `Schema at ${currentPath.join('.')} is not standard-schema compliant: missing '~standard' property.`, | |
| definition, | |
| }, | |
| ], | |
| }; | |
| } |
Closes #5