Skip to content

Instantly share code, notes, and snippets.

@shahab65
Last active December 3, 2019 12:00
Show Gist options
  • Save shahab65/5e4556f161897a124dcb836b0eca4e8e to your computer and use it in GitHub Desktop.
Save shahab65/5e4556f161897a124dcb836b0eca4e8e to your computer and use it in GitHub Desktop.
//import {Field, Form, Formik} from "formik";
// import * as Yup from "yup";

      <Formik
        enableReinitialize
        initialValues={calculatedFormInitialValues}
        validate={values => {
            let errors = {};
            if (values.responsible_user === "" && values.responsible_department === "") {
              errors.responsible_user = "One of these is required";
              errors.responsible_department = "One of these is required";
            }
            return errors;
          }}
        validationSchema={Yup.object().shape({
          first_name: Yup.string()
            .required('Required'),
        })}

        onSubmit={values => {
        }}
      >
        {({errors, touched, values}) => {
          return (
            <Form>
              <Field name='first_name' component={InputFieldFormik}
                     placeholder={'First Name'}/>
            </Form>
          )
        }}
      </Formik>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment