question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transform Empty String To Null

See original GitHub issue

I’ve been struggling getting this implementation to work as I expect. accountingId: Yup.string().nullable(true).default(null).transform(( function(value, originalValue) { if (!value) { return null; } return originalValue; })),

I am using this with Formik’s Validation Schema with the expectation that it will transform on submit – despite the validation running, it does not transform the empty string to null.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
jquensecommented, May 29, 2020

Formik, does run the transforms but it doesn’t pass back the transformed value to the onSubmit handler. You’d need to manually schema.cast(submittedValue) to get it

2reactions
osvaldokalvaitircommented, Mar 26, 2021

@titasPartikas Thanks for the answer. I preferred to make a function on the backend that transforms empty into null.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Converting empty string into null - mysql - Stack Overflow
$sql = "INSERT INTO STRANKEP (NAZIV, OIB, EMAIL, ADRESA, TELEFON) VALUES ('$NAZIV', CASE WHEN '$OIB' = '' THEN 'NULL', '$EMAIL', '$ADRESA', '$ ...
Read more >
FAQ: Is there any property to convert an empty string to NULL ...
No, there is no custom property that converts empty strings to NULL values in the source in PowerCenter. However, some functions could be ......
Read more >
Converting empty textbox to null instead of empty string - MSDN
cmd.Parameters.Add("@QuoteID", SqlDbType.Int, 4).Value = txtQuoteNumber.Text == String.Empty ? null : Convert.
Read more >
SQL SERVER - CONVERT Empty String To Null DateTime
Let us learn today how to CONVERT Empty String To Null DateTime. While I focus on SQL Server Performance Health Check, let us...
Read more >
Transform - Return null/empty string - Discussion and Questions
In case you are supplying the output of this transform to other transform it's advisable to have some kind of string instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found