Skip to content
Discussion options

You must be logged in to vote

First of all, that's not how you use Controller for custom input. Please read the documentation again:

For you needs, you can use validate and getValues to validate each field. Some thing like this:

function isFirstNameOrLastNameFilled() {
  const firstName= getValues('firstName')
  const lastName = getValues('lastName')

  const isValid = firstName || lastName

  if (!isValid) return 'Your error message here'
  return true
}

<Controller
  name="firstName"
  rules={{ validate: isFirstNameOrLastNameFilled }}
  render={ /* render the input here */ }
/>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bluebill1049
Comment options

Answer selected by bluebill1049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants