Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Update Error Message / HTTP Folder #27

Closed
wr125 opened this issue Sep 27, 2021 · 8 comments
Closed

Update Error Message / HTTP Folder #27

wr125 opened this issue Sep 27, 2021 · 8 comments

Comments

@wr125
Copy link

wr125 commented Sep 27, 2021

Think there might be another issue or something, as I've added Positive(), method to a field and is showing an error in http/update.go file. Removed it and it goes away. Issue also with Username which I do have but saying its undefined in the update file. I've pushed the repository to github so you can do a pull request on it and let us know.

@masseelch
Copy link
Owner

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

@wr125
Copy link
Author

wr125 commented Sep 27, 2021

try error upload

@masseelch
Copy link
Owner

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

@wr125
Copy link
Author

wr125 commented Sep 28, 2021

you can use the second branch copy.

@masseelch
Copy link
Owner

Please update elk to v0.4.8.

@wr125
Copy link
Author

wr125 commented Sep 28, 2021

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("pauline@gmail.com"),
		client.User.Create().SetUsername("patrick").SetPassword("patrick214").SetEmail("patick@gmail.com"),
		client.User.Create().SetUsername("jason").SetPassword("jason001").SetEmail("jason@gmail.com"),
		client.User.Create().SetUsername("anna").SetPassword("anna125").SetEmail("anna@gmail.com"),
		client.User.Create().SetUsername("Jack").SetPassword("jackson43").SetEmail("jackson@gmail.com"),

		// ...
	).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
			}),

@wr125
Copy link
Author

wr125 commented Sep 28, 2021

forgot to add; if s != s

@masseelch
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants