go-ozzo / ozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k stars 224 forks source link

is.Email not working for jon@doe.ca #152

Closed khanakia closed 3 years ago

khanakia commented 3 years ago

I am using this code and getting Error Email must be a valid email address so it seems not working for custom domains ?

func Validate()  {
    errors := validation.ValidateStruct(&a,
        validation.Field(&a.ID, validation.Required),
        validation.Field(&a.Email, validation.Required, is.Email),
    )
       fmt.Println(errors)
}

I think this is related to https://github.com/asaskevich/govalidator/pull/382

Can you update the govalidator package into your module so issue can fixed ?

I tested the govalidator package and it's working good. So please fix the issue ASAP my application is dependent on your package.

Working Playground: https://play.golang.org/p/Dao-5eF-ZMR

package main

import "github.com/asaskevich/govalidator"

func main() {

    type User struct {
        Email string `valid:"email"`
    }
    result, err := govalidator.ValidateStruct(User{"john@doe.ca"})
    if err != nil {
        println("error: " + err.Error())
    }
    println(result)
}
khanakia commented 3 years ago

I figured it out isEmail do the MX lookup and fails.

I used validation.Field(&a.Email, validation.Required, is.EmailFormat) and it works great.