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

Bug: postcode_iso3166_alpha2_field validation broken in v10.21.0 #1314

Open
2 tasks done
mikepilat opened this issue Aug 29, 2024 · 0 comments
Open
2 tasks done

Bug: postcode_iso3166_alpha2_field validation broken in v10.21.0 #1314

mikepilat opened this issue Aug 29, 2024 · 0 comments

Comments

@mikepilat
Copy link

mikepilat commented Aug 29, 2024

  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10.22.0

Issue, Question or Enhancement:

This PR released with v10.21.0 broke postcode_iso3166_alpha2_field validations.

I believe this open PR would fix it, but it has not been merged.

Code sample, to showcase or reproduce:

package main

import (
        "fmt"

        "github.com/go-playground/validator/v10"
)

type Example struct {
        PostCode    string `validate:"required,postcode_iso3166_alpha2_field=CountryCode"`
        CountryCode string `validate:"required,iso3166_1_alpha2"`
}

func main() {
        validate := validator.New(validator.WithRequiredStructEnabled())

        ex := Example{
                CountryCode: "US",
                PostCode:    "12345",
        }

        err := validate.Struct(ex)
        fmt.Println(err)
}

Under v10.22.0, this outputs:

Key: 'Example.PostCode' Error:Field validation for 'PostCode' failed on the 'postcode_iso3166_alpha2_field' tag

Under v10.20.0, the validation works as expected.

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

No branches or pull requests

1 participant