jquense / yup

Dead simple Object schema validation
MIT License
22.9k stars 933 forks source link

Field name with object path #134

Closed klis87 closed 7 years ago

klis87 commented 7 years ago

Is it possible to achieve sth like this currently?:

<Formik
  initialValues={{ nested: { value: 'nested value' } }}
  validationSchema={schema}
  onSubmit={(values, { setSubmitting }) => {
    handleSubmit(values);
    setSubmitting(false);
  }}
>
  {() => (
    <Form>
      <Field name="nested.value" />
      <button type="submit">Save</button>
    </Form>
  )}
</Formik>

I know I could use mapPropsToValues and mapValuesToPayload, but I find it really verbose and inconvenient for such a simple and common case. If I had deeply nested object, it would be even worse.

jquense commented 7 years ago

Hey there, seems like your question is formik specific and not really related to yup? You might want to try the formik repo. Might also want to look at react-formal, which allows this and also uses Yup, if formik doesn't cover your use case :)

klis87 commented 7 years ago

Ohh sorry, multitabs issue :)