Skip to content

feat(figue): integrate @standard-schema/spec to replace zod#9

Merged
CorentinTh merged 1 commit into
mainfrom
standard-schema
Jul 28, 2025
Merged

feat(figue): integrate @standard-schema/spec to replace zod#9
CorentinTh merged 1 commit into
mainfrom
standard-schema

Conversation

@CorentinTh

@CorentinTh CorentinTh commented Apr 2, 2025

Copy link
Copy Markdown
Owner

Closes #5

@CorentinTh CorentinTh requested a review from Copilot April 2, 2025 16:52
@CorentinTh CorentinTh self-assigned this Apr 2, 2025

This comment was marked as outdated.

@CorentinTh CorentinTh requested a review from Copilot July 28, 2025 11:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StandardSchemaV1 instead of ZodType
  • 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"

Comment thread src/figue.ts
}

if (validation.issues) {
return { issues: validation.issues.map(issue => ({ ...issue, path: currentPath, definition })) };

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
}))
};

Copilot uses AI. Check for mistakes.
Comment thread src/figue.ts
definition: ConfigDefinitionElement;
value: unknown;
currentPath: string[];
}): { config?: unknown; issues: ConfigIssue[] } {

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
}): { 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,
},
],
};
}

Copilot uses AI. Check for mistakes.
@CorentinTh CorentinTh merged commit 513af9a into main Jul 28, 2025
2 checks passed
@CorentinTh CorentinTh deleted the standard-schema branch July 28, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Use Stanrard Schema interface to support other validation libs

2 participants