Git Product home page Git Product logo

Comments (8)

masseelch avatar masseelch commented on August 24, 2024

I'll have a look. Is it the copy branch?

from elk.

wr125 avatar wr125 commented on August 24, 2024

try error upload

from elk.

masseelch avatar masseelch commented on August 24, 2024

That branch does not exist. Please provide a reproducible example, so I can have a look.

from elk.

wr125 avatar wr125 commented on August 24, 2024

you can use the second branch copy.

from elk.

masseelch avatar masseelch commented on August 24, 2024

Please update elk to v0.4.8.

from elk.

wr125 avatar wr125 commented on August 24, 2024

Receiving validation error on SetEmail
go run server.go

2021/09/28 13:33:42 failed adding user details to database: ent: validator failed for field "email": please enter a valid email address
func User(ctx context.Context, client *ent.Client) error {
	if err := client.User.CreateBulk(
		client.User.Create().SetUsername("pauline").SetPassword("paul834").SetEmail("[email protected]"),
		client.User.Create().SetUsername("patrick").SetPassword("patrick214").SetEmail("[email protected]"),
		client.User.Create().SetUsername("jason").SetPassword("jason001").SetEmail("[email protected]"),
		client.User.Create().SetUsername("anna").SetPassword("anna125").SetEmail("[email protected]"),
		client.User.Create().SetUsername("Jack").SetPassword("jackson43").SetEmail("[email protected]"),

		// ...
	).Exec(ctx); err != nil {
		return err
	}

validate

field.String("email").Unique().
			Match(regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")).
			Validate(func(s string) error {
				if s == s {
					return errors.New("please enter a valid email address")
				}
				return nil
			}),

from elk.

wr125 avatar wr125 commented on August 24, 2024

forgot to add; if s != s

from elk.

masseelch avatar masseelch commented on August 24, 2024

This is not an error with elk. Please refrain from using the GitHub Issues for questions regarding Ent. That is what the Slack and Discord channels are for.

You mean this Validator?

Validate(func(s string) error {
	if s != s {
		return errors.New("please enter a valid email address")
	}
	return nil
})

That will always return nil. For literally every string there is. If swapped to if s == s it will always fail. https://play.golang.org/p/Mlme54tfutN

from elk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.