Skip to content

Commit

Permalink
Add FQDN en translation (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakito committed Jan 30, 2023
1 parent 5aa5f93 commit 3201fe4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ _testmain.go
*.txt
cover.html
README.html
.idea
5 changes: 5 additions & 0 deletions translations/en/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
translation: "{0} must contain a valid MAC address",
override: false,
},
{
tag: "fqdn",
translation: "{0} must be a valid FQDN",
override: false,
},
{
tag: "unique",
translation: "{0} must contain unique values",
Expand Down
5 changes: 5 additions & 0 deletions translations/en/en_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func TestTranslations(t *testing.T) {
IPAddrv6 string `validate:"ip6_addr"`
UinxAddr string `validate:"unix_addr"` // can't fail from within Go's net package currently, but maybe in the future
MAC string `validate:"mac"`
FQDN string `validate:"fqdn"`
IsColor string `validate:"iscolor"`
StrPtrMinLen *string `validate:"min=10"`
StrPtrMaxLen *string `validate:"max=1"`
Expand Down Expand Up @@ -226,6 +227,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.MAC",
expected: "MAC must contain a valid MAC address",
},
{
ns: "Test.FQDN",
expected: "FQDN must be a valid FQDN",
},
{
ns: "Test.IPAddr",
expected: "IPAddr must be a resolvable IP address",
Expand Down

0 comments on commit 3201fe4

Please sign in to comment.