X Tutup
Skip to content

fix: standard schema validation works with arktype (#5110)#5144

Open
logaretm wants to merge 1 commit intomainfrom
fix/5110-arktype-standard-schema
Open

fix: standard schema validation works with arktype (#5110)#5144
logaretm wants to merge 1 commit intomainfrom
fix/5110-arktype-standard-schema

Conversation

@logaretm
Copy link
Owner

@logaretm logaretm commented Mar 4, 2026

Summary

  • Fixes v5 - Incompatible with arktype even though it uses standard schema #5110: arktype schemas are callable (typeof === 'function'), so isStandardSchema() was rejecting them because isObject() only accepts typeof === 'object'
  • Updated isStandardSchema to accept both objects and functions with the ~standard property, matching the standard schema spec
  • Added comprehensive tests for isStandardSchema covering callable schemas, primitives, arrays, and plain objects

Details

The root cause was in packages/vee-validate/src/utils/assertions.ts:

// Before (broken for arktype)
export function isStandardSchema(value: unknown): value is StandardSchemaV1 {
  return isObject(value) && '~standard' in (value as unknown as StandardSchemaV1);
}

// After (works with arktype and any callable standard schema)
export function isStandardSchema(value: unknown): value is StandardSchemaV1 {
  return !!value && (typeof value === 'object' || typeof value === 'function') && '~standard' in (value as Record<PropertyKey, unknown>);
}

Arktype schemas are both functions and standard schemas — they are callable but also have the ~standard property. The isObject() utility uses typeof obj === 'object' which returns false for functions, causing isStandardSchema() to return false for arktype schemas. This made vee-validate fall through to the isCallable(rules) branch, which tried to call the arktype schema as a plain validation function, leading to TypeError: rule is not a function.

Test plan

  • Added 6 new tests for isStandardSchema in assertions.spec.ts
  • Tests cover: plain object standard schemas, callable standard schemas (arktype-like), plain functions, primitive values, arrays, and plain objects without ~standard
  • All 361 existing tests continue to pass (3 pre-existing failures unrelated to this change)

🤖 Generated with Claude Code

Arktype schemas are callable (typeof === 'function'), so isStandardSchema()
was rejecting them because isObject() only accepts typeof === 'object'.
Updated the check to accept both objects and functions with the ~standard
property, matching the standard schema spec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 4, 2026 07:02
@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for vee-validate-v5 ready!

Name Link
🔨 Latest commit 3e2b58c
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-v5/deploys/69a7d919b8563d00088a41b9
😎 Deploy Preview https://deploy-preview-5144--vee-validate-v5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 3e2b58c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for vee-validate-docs canceled.

Name Link
🔨 Latest commit 3e2b58c
🔍 Latest deploy log https://app.netlify.com/projects/vee-validate-docs/deploys/69a7d9191b07a40008fd1516

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes vee-validate’s standard schema detection to support callable schemas (e.g., arktype), aligning isStandardSchema() with the standard schema spec so schema-based validation routing works correctly.

Changes:

  • Updated isStandardSchema() to accept both objects and functions that expose the ~standard property.
  • Added focused unit tests covering callable schemas, plain object schemas, and non-schema inputs.
  • Added a changeset for a patch release of vee-validate.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/vee-validate/src/utils/assertions.ts Expands isStandardSchema type guard to include callable schemas with ~standard.
packages/vee-validate/tests/utils/assertions.spec.ts Adds test coverage for isStandardSchema across expected/edge input shapes.
.changeset/fix-5110-arktype-compat.md Declares a patch release note for the arktype/standard schema compatibility fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

v5 - Incompatible with arktype even though it uses standard schema

2 participants

X Tutup