repocrypts / Validator

Client-side javascript validator library ports from Laravel 5.2
MIT License
46 stars 22 forks source link

[ERROR] Email is not a valid email address #8

Closed ghost closed 5 years ago

ghost commented 6 years ago

Hello,

I don’t understand why checking the email address does not work. I tested the Regex rule (line 790), the library code seems to be good but an error on the email address is detect and blocks the continuation of the code.

An idea of what could be involved?

The email address is valid, there is no empty space before or after, the Regex passes the tests though: https://regex101.com/r/dZr528/1

Version of library : https://unpkg.com/Validator (CDN) Browser : Chrome (Version 62.0.3202.89 / 64 bits) Code :

var v = Validator.make({
                "name" : $form.find('input[name="name"]'),
                "first-name" : $form.find('input[name="first-name"]'),
                "email" : $form.find('input[name="email"]'),
                "phone" : $form.find('input[name="phone"]'),
                "function" : $form.find('input[name="function"]'),
                "details" : $form.find('input[name="details"]'),
            }, {
                "name" : "required",
                "first-name" : "required",
                "email" : "required|email",
                "phone" : "required",
                "function" : "required",
                "details" : ""
            });

            if (v.fails()) {
                var errors = v.getErrors();
                console.log(errors);

                $form.find(".loader").animate({"opacity":"0"});
                setTimeout(function(){
                    $form.find(".loader").css({"display":"none"});
                    $form.find(".alert").fadeIn();
                }, 500);
                $form.find(".form").animate({"opacity" : "1"});

                return false;
            }

Error message :

{"email":["The email must be a valid email address."]}