Skip to content

~standard.validate returns issue.path as a string instead of an array (violates Standard Schema spec) #146

Description

@JosephMarotte

Package version

4.4.0

Describe the bug

Describe the bug

VineJS's Standard Schema implementation sets issue.path to the dotted field string (e.g. "user.name"), but the Standard Schema spec requires path to be an array of segments.

From @standard-schema/spec: (

interface Issue {
  readonly message: string;
  /** The path of the issue, if any. */
  readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
}

Reproduction

import vine from '@vinejs/vine'

const schema = vine.create(vine.object({ user: vine.object({ name: vine.string() }) }))
const result = await schema['~standard'].validate({ user: {} })

console.log(result.issues[0].path)               // "user.name"   ❌
console.log(Array.isArray(result.issues[0].path)) // false
// Spec expects: ["user", "name"]

Root cause

src/vine/validator.ts, in the ~standard.validate implementation:

return {
  issues: error?.messages.map((message: any) => {
    return {
      ...message,
      path: message.field,   // 👈 message.field is a dotted string, not an array
    }
  }),
}

message.field is the dotted field path ("user.name"), assigned directly to path.

Impact

Because a JS string is array-like (has length and numeric indices), consumers that iterate path (e.g. TanStack Form, don't throw — they iterate the string character by character ("u", "s", "e", "r", …). The failure is silent: validation fails but errors are never attached to the right fields, so no messages show up. This makes VineJS unusable as a TanStack Form validator without a runtime monkey-patch.

Expected behavior

path should be an array of segments per the spec — e.g. ["user", "name"]

Reproduction repo

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions