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

validation_error bug in the demo example #20

Open
viktorix opened this issue Sep 6, 2016 · 3 comments
Open

validation_error bug in the demo example #20

viktorix opened this issue Sep 6, 2016 · 3 comments

Comments

@viktorix
Copy link

viktorix commented Sep 6, 2016

It looks like there's a bug with how error validation_error function works.
https://github.com/mailgun/validator-demo/blob/master/index.html#L88

// if email is invalid
      function validation_error(error_message) {
        $('#status').html(error_message);
      }

$('#status').html(error_message); does not fire.

The "Address is invalid." check and error message does work properly, but it is fired inside validation_success function as the last remaining "else" condition.

You can easily test this by removing $('#status').html(error_message); and testing validator. You'll see it still works just fine. This is a problem because if we want to do something else when email is invalid, let's say addClass it does not work.

@jeffreykemp
Copy link

I think that is how it is supposed to work.

If the ajax call fails, you expect the validation error to run.

If the ajax call succeeds, you expect the validation success to run. The result of the validation might be that the email address appears to be invalid, but this is still a "success" as far as the validator is concerned.

Unless I'm mistaken :)

@viktorix
Copy link
Author

viktorix commented Sep 8, 2016

Yea, that might be the case. If it is, maybe it's the comment that explains what the function does needs to be re-worded: if email is invalid

@jeffreykemp
Copy link

That's just the sample code - agreed the comment could be misleading

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