jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
33.98k stars 2.79k forks source link

Nested field validation #1845

Open seberik opened 5 years ago

seberik commented 5 years ago

I have nested fields with number inputs and can't get the validation to work properly. Not sure if this is a problem with formik or yup / how the validation schema is declared but I'll start asking here.

In the example I have two fields which represents numbers and defaults to empty string. The validation works for the first fields but I can not get it to behave the same for the nested field. When I touch the field but don't type anything it returns social.facebook must be a `number` type, but the final value was: `NaN` (cast from the value `""`).

Example: https://codesandbox.io/s/formik-nested-schema-example-q4dlj?fontsize=14

Jokinen commented 4 years ago

While searching for a related problem I came across this issue that explains the different behaviour with nesting:

https://github.com/jaredpalmer/formik/issues/805