Skip to content

Use Zod for Shift clipboard payload validation #137

Description

@kostyafarber

Problem

Clipboard paste reads unknown text from the OS clipboard and tries to interpret it as Shift content, SVG, or another supported external format. The current native Shift payload path uses hand-written boolean validators.

That makes diagnostics weak: invalid JSON, schema mismatch, stale validator API drift, and unsupported external text can all collapse into similar paste failures.

Direction

Use Zod for the Shift clipboard envelope because this is an external boundary and not a hot path.

The parser should validate the full payload envelope, then return a typed ShiftContent or a structured unsupported result with a reason.

Acceptance criteria

  • Add a Zod schema for the shift/glyph-data clipboard payload.
  • Validate the full envelope, not only content.
  • Reject unsupported future versions explicitly.
  • Preserve arbitrary external plain text as unsupported, not an exception.
  • Return enough reason information for debugging without logging clipboard contents by default.
  • Cover valid round-trip, invalid JSON, wrong format, future version, malformed contour/point content, and arbitrary plain text.

Obsidian context: Ticket - Clipboard Zod Validation.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions