Skip to content

feat(Arktype): Adds ability to nest objects or declare specific keys in an array in FormData #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2025

Conversation

jhechtf
Copy link
Owner

@jhechtf jhechtf commented Feb 7, 2025

TL;DR

Enhanced form data parsing to better handle complex array and object structures in FormData submissions.

What changed?

  • Introduced a new MagicObject type to handle array and object conversions
  • Added regex patterns for name key extraction and digit checking
  • Improved handling of array-like form data entries with indexed keys
  • Added support for nested form data structures
  • Enhanced error handling with console warnings for duplicate keys
  • Added new test case for mixed array and single value submissions

How to test?

  1. Submit form data with array notation (e.g., names[], ages[])
  2. Test with indexed arrays (e.g., users[0], users[1])
  3. Verify mixed submissions with both array and single value fields
  4. Check that duplicate keys trigger console warnings
  5. Validate that array-like structures are properly converted to JS arrays

Why make this change?

The previous implementation had limitations when handling complex form data structures. This update provides more robust parsing of form data, especially for cases involving arrays and nested data structures, making it more flexible for real-world form submissions.

Copy link

changeset-bot bot commented Feb 7, 2025

🦋 Changeset detected

Latest commit: 54ee164

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

This PR includes changesets to release 1 package
Name Type
@jhecht/arktype-utils Minor

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

Copy link
Owner Author

jhechtf commented Feb 7, 2025

@jhechtf jhechtf marked this pull request as ready for review February 7, 2025 20:44
@jhechtf jhechtf force-pushed the feat/update-formdata-for-nested-objects branch 2 times, most recently from 2681c24 to 15223be Compare February 7, 2025 20:50
@jhechtf jhechtf force-pushed the feat/update-formdata-for-nested-objects branch from 15223be to 54ee164 Compare February 7, 2025 20:54
@jhechtf jhechtf changed the base branch from feat/add-jsr-test-package to main February 7, 2025 20:54
Copy link
Owner Author

jhechtf commented Feb 8, 2025

Merge activity

  • Feb 8, 1:04 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Feb 8, 1:04 AM EST: A user merged this pull request with Graphite.

@jhechtf jhechtf merged commit 1d9a099 into main Feb 8, 2025
4 checks passed
@jhechtf jhechtf deleted the feat/update-formdata-for-nested-objects branch February 8, 2025 06:04
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