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

Validate function documentation #1120

Open
benlieb opened this issue Jan 24, 2025 · 0 comments
Open

Validate function documentation #1120

benlieb opened this issue Jan 24, 2025 · 0 comments

Comments

@benlieb
Copy link

benlieb commented Jan 24, 2025

Great library, much appreciated!

That said, I can't find any docs on the validate function except:

Image

It doesn't say what to return to influence the error creation etc.

I asked copilot and it suggested:

          rules={{
            required: 'required',
            validate: (value) => {
              if (value.split(' ').length > 1) {
                return 'no spaces allowed'
              }
              return true;
            }
          }}

But it seems the return true may not be necessary? This seems to work fine?

          rules={{
            required: 'required',
            validate: (value) => {
              if (value.split(' ').length > 1)
                return 'no spaces allowed'
            }
          }}
@bluebill1049 bluebill1049 transferred this issue from react-hook-form/react-hook-form Jan 25, 2025
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

No branches or pull requests

1 participant