Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(context): inject context into yup context #30

Conversation

Paul-Vandell
Copy link
Contributor

Hey there,
-> #29
Test + context injected
I prefer to don't dive test because i will make another mr for -> #26 (comment).
And then push test to 100%

Copy link
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! LGTM.

@Paul-Vandell
Copy link
Contributor Author

Paul-Vandell commented Jul 16, 2020

I go to -> #26 (comment).
And then i'll really like to fix that if you can help me as much as you can -> react-hook-form/react-hook-form#2222

@bluebill1049
Copy link
Member

@Vandell63 you happy for this PR to be merged?

@Paul-Vandell
Copy link
Contributor Author

@Vandell63 you happy for this PR to be merged?

Of course yes :) if it is all fine for you 👍

@bluebill1049 bluebill1049 merged commit 15969cc into react-hook-form:master Jul 17, 2020
@tommedema
Copy link

Tried to migrate to react-hook-form 6.0.7 with "@hookform/resolvers": "^0.0.6", but my yup schema is not actually used and validation passes with invalid values:

  const {
    register,
    handleSubmit,
    watch,
    errors,
    formState,
    reset,
    setValue,
  } = useForm<IFormValues>({
    context: {
      renderFields,
      isParticipantsRequired,
    },
    resolver: yupResolver(formSchema, {
      context: {
        renderFields,
        isParticipantsRequired,
      }
    })
  })

@bluebill1049
Copy link
Member

@tommedema provide a codesandbox

@Paul-Vandell
Copy link
Contributor Author

@tommedema please can you retry with this shape instead and give me your feedback ?

  const {
    register,
    handleSubmit,
    watch,
    errors,
    formState,
    reset,
    setValue,
  } = useForm<IFormValues>({
    context: {
      renderFields,
      isParticipantsRequired,
    },
    resolver: yupResolver(formSchema)
  })

Or if you want your context to be used inside of the yup options with abortEarly set to false

  const {
    register,
    handleSubmit,
    watch,
    errors,
    formState,
    reset,
    setValue,
  } = useForm<IFormValues>({
    resolver: yupResolver(formSchema, {
      abortEarly: false,
      context: {
        renderFields,
        isParticipantsRequired,
      }
    })
  })

@Paul-Vandell Paul-Vandell mentioned this pull request Jul 19, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants