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

NonStandard Validators - Import Bug #521

Closed
teejays opened this issue Sep 29, 2019 · 2 comments
Closed

NonStandard Validators - Import Bug #521

teejays opened this issue Sep 29, 2019 · 2 comments
Assignees
Labels

Comments

@teejays
Copy link
Contributor

teejays commented Sep 29, 2019

Package version eg. v8, v9:

v9

Issue, Question or Enhancement:

When using the non-standard validators, the validation functions do not implement go-playground/validator.v9.Func type because the non-standard/validators package use github.com/andreiavrammsd/validator.Func instead.

See: https://github.com/go-playground/validator/blob/v9.29.1/non-standard/validators/notblank.go#L7

Code sample, to showcase or reproduce:

package mypackage

import (
	"gopkg.in/go-playground/validator.v9"
	nonstandard "gopkg.in/go-playground/validator.v9/non-standard/validators"
)

var validate *validator.Validate

func init() {
	validate = validator.New()
	validate.RegisterValidation("notblank", nonstandard.NotBlank)
}

This does not compile because of:
cannot use nonstandard.NotBlank (value of type func(fl validator.FieldLevel) bool) as validator.v9.Func value in argument to validate.RegisterValidation

Fix:

Replace import of github.com/andreiavrammsd/validator with go-playground/validator.v9 on here. Happy to submit a PR.

@teejays teejays changed the title NonStandard Validators NonStandard Validators - Import Bug Sep 29, 2019
teejays added a commit to teejays/validator that referenced this issue Sep 29, 2019
@teejays
Copy link
Contributor Author

teejays commented Sep 29, 2019

PR#522, if it makes sense.

@deankarn deankarn self-assigned this Sep 29, 2019
@deankarn deankarn added the bug label Sep 29, 2019
deankarn added a commit that referenced this issue Sep 29, 2019
Issue #521: Non-standard validators import path fix
@deankarn
Copy link
Contributor

Merged today and release in v9.30.0

fairyhunter13 added a commit to fairyhunter13/validator that referenced this issue Jul 12, 2020
fairyhunter13 added a commit to fairyhunter13/validator that referenced this issue Jul 12, 2020
Issue go-playground#521: Non-standard validators import path fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants