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

Custom validations on multi select not getting Array #248

Closed
bostrom opened this issue Aug 23, 2019 · 9 comments
Closed

Custom validations on multi select not getting Array #248

bostrom opened this issue Aug 23, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@bostrom
Copy link

bostrom commented Aug 23, 2019

I'm trying to validate a "select multiple" input using a custom validation in the register callback like so

        <select
          name="multiSelect"
          multiple
          ref={register({
            validate: value => Array.isArray(value) && value.length > 1
          })}
        >
          <option value="opt1">Option 1</option>
          <option value="opt2">Option 2</option>
          <option value="opt3">Option 3</option>
          <option value="opt4">Option 4</option>
        </select>

However, the value passed to the validator function is always a String, the value of which is the topmost selected option.

Codesandbox available here https://codesandbox.io/embed/react-hook-form-1m47u

Is this a bug, or am I doing something wrong?

@bluebill1049 bluebill1049 added the bug Something isn't working label Aug 23, 2019
@bluebill1049 bluebill1049 self-assigned this Aug 23, 2019
@bluebill1049
Copy link
Member

Thanks for the detailed issue report, verified and it's a bug. I will patch it soon.

@bluebill1049
Copy link
Member

bluebill1049 commented Aug 24, 2019

Thanks. this have been fixed: https://codesandbox.io/s/react-hook-form-qefbn (deleted already)

here is the beta version: 3.22.2-beta.7

@bluebill1049
Copy link
Member

This patch should be released soon :) if there is no other issue found

@bluebill1049 bluebill1049 reopened this Aug 24, 2019
@bluebill1049 bluebill1049 added this to In progress in React Hook Form Aug 26, 2019
@bostrom
Copy link
Author

bostrom commented Aug 26, 2019

Wow, that was fast! 💪

Thanks!

@bluebill1049
Copy link
Member

Thanks releasing tonight 🤗

@bluebill1049 bluebill1049 moved this from In progress to Done in React Hook Form Aug 26, 2019
@bluebill1049
Copy link
Member

the patch has been released, please close this issue if works fine :)

@sandroweb
Copy link

Thanks. this have been fixed: https://codesandbox.io/s/react-hook-form-qefbn

here is the beta version: 3.22.2-beta.7

Yout CodeSandbox is not exists. 404 error

@bluebill1049
Copy link
Member

@sandroweb what's the issue? the problem is resolved, CSB was limited at the time, so i only had 50 before to manage.

@sandroweb
Copy link

@sandroweb what's the issue? the problem is resolved, CSB was limited at the time, so i only had 50 before to manage.

I asked yesterday because the solution was not clear for me, but I solve. Thank you!

@bluebill1049 bluebill1049 removed their assignment Aug 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants