Skip to content

Commit ff275f1

Browse files
committed
fix: Handle null form field values
1 parent 830d41c commit ff275f1

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Updates custom framework to following correct CollectingResponse flow order (to ensure that subsequent calls to the `sendJSONResponse` doesn't overwrite the response).
1818
- Updated/expanded plugin support.
1919
- Reworked internals to avoid dynamic requires and circular dependencies
20+
- Fix signup error when a form field value is null
2021

2122
## [23.0.1] - 2025-07-31
2223

lib/build/recipe/emailpassword/api/utils.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/emailpassword/api/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ async function validateFormOrThrowError(
109109

110110
// Add the not optional error if input is not passed
111111
// and the field is not optional.
112-
const isValidInput =
113-
!!input &&
114-
((typeof input.value === "string"
115-
? input.value.length > 0
116-
: input.value !== null && typeof input.value !== "undefined") ||
117-
(typeof input.value === "object" && Object.values(input.value).length > 0));
112+
const hasNonEmptyStringValue = typeof input?.value === "string" && input.value.length > 0;
113+
const hasNonNullishNonStringValue =
114+
typeof input?.value !== "string" && input?.value !== null && input?.value !== undefined;
115+
116+
const isValidInput = !!input && (hasNonEmptyStringValue || hasNonNullishNonStringValue);
117+
118118
if (!formField.optional && !isValidInput) {
119119
validationErrors.push({
120120
error: "Field is not optional",

0 commit comments

Comments
 (0)