Skip to content

Conversation

@roottool
Copy link
Owner

Description

This PR adds a comprehensive set of TypeScript examples demonstrating safe-formdata usage patterns and best practices.

Boundary Checklist (Required)

safe-formdata enforces a strict trust boundary for FormData.
If any item below does not apply, this change likely does not belong here.

  • No interpretation

    • Key names are treated as opaque strings
    • No structural inference ([], ., brackets, paths, etc.)
  • No silent behavior

    • No merging, overwriting, auto-fixing, or implicit resolution
    • All boundary violations are reported explicitly
  • Boundary respected

    • No validation, coercion, schema, framework conventions, or business logic

📘 Boundary rules & non-goals:
https://github.com/roottool/safe-formdata/blob/main/AGENTS.md

Type of Change

  • Bug fix
  • Security fix
  • Documentation
  • Refactoring (no behavior change)
  • Tests
  • Tooling / CI

Testing

Added Examples:

  1. 00-basic.ts - Demonstrates:

    • Basic field access from FormData
    • Validation guard pattern (result.data === null)
    • Explicit type narrowing for string | File values
  2. 01-file-upload.ts - Demonstrates:

    • File value handling from multipart/form-data
    • Type narrowing with instanceof File
    • File size and MIME type validation
  3. 02-field-presence.ts - Demonstrates:

    • Optional field handling pattern
    • Explicit presence checking with in operator
    • No implicit "optional" field concept
  4. 03-error-handling.ts - Demonstrates:

    • Validation failure handling
    • Issue inspection and structured error reporting
    • Duplicate key rejection (boundary enforcement)
  5. 04-integration-fetch.ts - Demonstrates:

    • Real-world Request handler integration
    • Parsing FormData from HTTP requests
    • Field validation and HTTP response patterns

CI Updates:

  • Added check:type:example script to package.json
  • Updated CI workflow to typecheck examples
  • Removed unused .tsx file filter

All examples pass TypeScript type checking and demonstrate boundary-compliant patterns.

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

@roottool roottool self-assigned this Dec 29, 2025
@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f121fda) to head (e68c984).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #26   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           22        22           
  Branches         6         6           
=========================================
  Hits            22        22           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roottool roottool merged commit ffd0dad into main Dec 29, 2025
12 checks passed
@roottool roottool deleted the feature/add-examples branch December 29, 2025 00:55
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.

2 participants