Skip to content

fix: omit empty optional fields from payloads#16

Open
Luffy-D-Zoro wants to merge 1 commit into
bsoc-bitbyte:mainfrom
Luffy-D-Zoro:fix/empty-optional-fields-validation
Open

fix: omit empty optional fields from payloads#16
Luffy-D-Zoro wants to merge 1 commit into
bsoc-bitbyte:mainfrom
Luffy-D-Zoro:fix/empty-optional-fields-validation

Conversation

@Luffy-D-Zoro

@Luffy-D-Zoro Luffy-D-Zoro commented Jun 9, 2026

Copy link
Copy Markdown

What

Fixes #14

This PR fixes validation failures when optional form fields are submitted empty.
Previously, some optional frontend fields were sent as null:

  • notes in PostRide.jsx
  • maxFare in PostIntent.jsx

The backend schemas treat these fields as optional, not nullable, so sending null caused validation to fail.

This PR changes the empty optional field values from null to undefined.

When the request payload is stringified, fields with undefined values are omitted from the JSON body. This matches the backend schemas where these fields are optional.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Proof of work

Tested locally:

  • Posting a ride without notes works.
  • Posting a ride with notes works.
  • Posting an intent without max fare works.
  • Posting an intent with max fare works.

Checklist

  • I claimed this issue before starting work
  • Branch name follows the convention (feature/, fix/, docs/)
  • Commits follow Conventional Commits format
  • CI is passing (lint, prettier, build)
  • I have self-reviewed my own code
  • Any non-obvious decisions are explained with a comment in the code

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.

[BUG] Validation fails when optional form fields are submitted empty

1 participant