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

Rule with remote validation, blocked due to security settings, but valid() still evaluates to true #1044

Closed
QuintinS opened this issue Mar 22, 2014 · 5 comments

Comments

@QuintinS
Copy link

Hi,

Thanks for an awesome plugin - it's sped up validation tenfold for me and it's a joy to use!

I've noticed a possible issue.

I was working in a localhost environment and using a "remote" rule to validate a domain name and an email address field remotely. On the local environment, these rules failed due to HTTP security restrictions.

However, the problem I was having was that the form wasn't posting, at all. At first I thought this might be because the form wasn't valid, but I console.logged the valid() method, and it returned true. As such, I thought that there must have been some kind of event blocking going on that prevented the form from submitting.

But, when I published my code to a live environment to check it, the issue disappeared.

So, it seems that the "remote" method validates the form, but if there is an element that is validated remotely, that validation won't be counted in the valid() method.

@jzaefferer
Copy link
Collaborator

I don't see anything there that can be attributed to this plugin. If it works on one environment, its not the plugins fault if it doesn't work in the other. Maybe I'm missing something, but I can't tell without a reproducible example.

@QuintinS
Copy link
Author

Absolutely... Although the environment point wasn't really my point.

I think that the valid() method should return as true only if the form is fully valid. Because the remote rules couldn't reach the server with the validation scripts on, it couldn't check the elements the rules were applied to, but the elements were still considered valid and valid() evaluated to true.

I'd be happy to send you my code if that would help.

@QuintinS
Copy link
Author

To use my e-mail field as an example:

registerEmail: { required: true, email:true, remote: "http://..."}

To my mind, the element should only have been considered valid if all three rules checked out.

The field was filled in - required == true.
The field was formatted as a valid e-mail - email == true.
The field was told to check it against an existing list of e-mails with the remote rule, but couldn't reach the remote server - remote == false.

If you follow my thinking?

And yet the valid() still evaluated to true.

@jzaefferer
Copy link
Collaborator

Okay, gotcha, that wasn't clear before. I don't have a good answer though, since its hard to express a pending state with booleans. The remote methods actually returns a magic string ("pending" or something like that), but the valid() method will claim its valid anyway.

I've logged a new issue, #1045 - that won't get addressed any time soon, since returning false might be also wrong, but at least others can chime in there and I can deal with that when I, eventually, get to rewrite this whole plugin.

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

2 participants