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

Don't validate empty (null) value just return false #1

Merged
merged 2 commits into from
Mar 30, 2023

Conversation

Shonetow
Copy link
Contributor

I noticed an issue when trying to submit a form without checking the hCaptcha button. It gave me this error:

Panfu\Laravel\HCaptcha\HCaptcha::validate(): Argument #1 ($token) must be of type string, null given

To fix it, I added a ternary operator that checks if the value is empty and returns false if it is.

Let me know what you think!

Copy link
Collaborator

@teampanfu teampanfu left a comment

Choose a reason for hiding this comment

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

Glad you noticed and thanks for your pull request!

However, I would adjust the validate function instead and make $token nullable by putting a question mark in front of it. The function itself already checks if the value is empty and then returns false.

If you can just change that, I can merge your pull request.

@Shonetow
Copy link
Contributor Author

Of course, it makes more sense now that I've actually looked at the validate function. 😁

@teampanfu teampanfu merged commit 0eff939 into teampanfu:main Mar 30, 2023
@teampanfu
Copy link
Collaborator

Perfect, I've merged it and am getting a version ready for Packagist.

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.

2 participants