Skip to content

Conversation

@jcap97
Copy link

@jcap97 jcap97 commented Dec 27, 2025

πŸ”— Linked issue

Related to #3524 - only adding implementation for Effect Schema since #3524 only support valibot and zod

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Nuxt Content only currently support Zod and Valibot for the StandardSchemaV1 and JSON Schema. Effect Schema both support the StandardSchemaV1 and JSON Schema but it is not supported by Nuxt Content

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Dec 27, 2025

Someone is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 27, 2025

npm i https://pkg.pr.new/@nuxt/content@3662

commit: f8ac427

@jcap97 jcap97 changed the title feat: adopt Effect Schema as a StandardSchemaV1 and JSON Schema validator feat: add Effect Schema as a StandardSchemaV1 and JSON Schema validator Dec 27, 2025
Copy link

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

The Effect Schema implementation is never registered in the validators context, so it will never be used even when the package is installed. The actual toJSONSchema implementation will never be called.

View Details
πŸ“ Patch Details
diff --git a/src/utils/dependencies.ts b/src/utils/dependencies.ts
index fd5eb804..fde3d6d3 100644
--- a/src/utils/dependencies.ts
+++ b/src/utils/dependencies.ts
@@ -76,4 +76,7 @@ export async function initiateValidatorsContext() {
     nuxtContentContext().set('zod3', await import('./schema/zod3'))
     nuxtContentContext().set('zod4', await import('./schema/zod4'))
   }
+  if (await isPackageInstalled('effect')) {
+    nuxtContentContext().set('effect', await import('./schema/effect'))
+  }
 }

Analysis

Effect Schema handler not registered in initiateValidatorsContext()

What fails: The initiateValidatorsContext() function in src/utils/dependencies.ts (lines 71-79) only registers handlers for Valibot and Zod schema validators, but does not register the Effect schema handler. This causes the default error handler to be used instead of the actual Effect implementation, preventing Effect Schema from working.

How to reproduce:

  1. Install the effect package in a project using @nuxt/content
  2. Create a collection with an Effect schema:
import { Schema as S } from 'effect'
import { defineCollection } from '@nuxt/content'

export const posts = defineCollection({
  type: 'page',
  source: 'posts/**',
  schema: S.Struct({
    title: S.String,
    author: S.String,
  })
})
  1. Try to use the collection - it will fail with "Effect is not installed" error even though the package IS installed

Result: When defineCollection() calls nuxtContentContext().get('effect'), it receives the default error handler from src/utils/context.ts that throws: "It seems you are using Effect Schema for collection schema, but Effect is not installed"

Expected: Should return the actual implementation from src/utils/schema/effect.ts which uses JSONSchema.make() to convert the schema

Fix applied: Added Effect schema registration to initiateValidatorsContext():

if (await isPackageInstalled('effect')) {
  nuxtContentContext().set('effect', await import('./schema/effect'))
}

This matches the same pattern used for Valibot and Zod registration, ensuring the real Effect schema handler is properly registered when the package is installed.

@jcap97 jcap97 changed the title feat: add Effect Schema as a StandardSchemaV1 and JSON Schema validator feat: add effect schema as part of the standard and JSON schema implementation Dec 28, 2025
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.

1 participant