Skip to content

Commit f65db98

Browse files
authored
feat: add translations for alphaspace and alphanumspace tags in indonesian (#1522)
This pull request adds support for two new validation tags, `alphaspace` and `alphanumspace`, to the Indonesian translations. It also updates the corresponding unit tests to ensure these new tags are properly validated and translated. **Translation additions:** * Added Indonesian translation for the `alphaspace` validation tag, indicating that a field may only contain alphabetic characters and spaces. * Added Indonesian translation for the `alphanumspace` validation tag, indicating that a field may only contain alphanumeric characters and spaces. **Testing improvements:** * Updated the `TestStringTagsTranslations` test struct and test cases to include fields for `Alphaspace` and `Alphanumspace`, and added invalid test values for both. [[1]](diffhunk://#diff-e71a6006a2e0721801e0d7233ec0aa3d5f2d250e037b05bcd8373d1fad2c7d09R402-R403) [[2]](diffhunk://#diff-e71a6006a2e0721801e0d7233ec0aa3d5f2d250e037b05bcd8373d1fad2c7d09R430-R431) * Added expected error messages for the new validation tags to the test assertions, ensuring the translations are correct.## Fixes Or Enhances **Make sure that you've checked the boxes below before you submit PR:** - [x] Tests exist or have been written that cover this particular change. @go-playground/validator-maintainers
1 parent 1f5bae4 commit f65db98

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

translations/id/id.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
258258
translation: "{0} hanya dapat berisi karakter alfanumerik",
259259
override: false,
260260
},
261+
{
262+
tag: "alphaspace",
263+
translation: "{0} hanya dapat berisi karakter alfabet dan spasi",
264+
override: false,
265+
},
266+
{
267+
tag: "alphanumspace",
268+
translation: "{0} hanya dapat berisi karakter alfanumerik dan spasi",
269+
override: false,
270+
},
261271
{
262272
tag: "alphanumunicode",
263273
translation: "{0} hanya boleh berisi karakter alfanumerik unicode",

translations/id/id_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ func TestStringTagsTranslations(t *testing.T) {
399399
// TestStringTags for string validations
400400
type TestStringTags struct {
401401
Alpha string `validate:"alpha"`
402+
Alphaspace string `validate:"alphaspace"`
403+
Alphanumspace string `validate:"alphanumspace"`
402404
Alphanum string `validate:"alphanum"`
403405
AlphanumUni string `validate:"alphanumunicode"`
404406
AlphaUni string `validate:"alphaunicode"`
@@ -425,6 +427,8 @@ func TestStringTagsTranslations(t *testing.T) {
425427
// init test struct with invalid values
426428
test := TestStringTags{
427429
Alpha: "123", // should only contain letters
430+
Alphaspace: "abc3", // should only contain letters and spaces
431+
Alphanumspace: "abc!", // should only contain letters, numbers, and spaces
428432
Alphanum: "!@#", // should only contain letters and numbers
429433
AlphanumUni: "!@#", // should only contain unicode letters and numbers
430434
AlphaUni: "123", // should only contain unicode letters
@@ -464,6 +468,14 @@ func TestStringTagsTranslations(t *testing.T) {
464468
ns: "TestStringTags.Alpha",
465469
expected: "Alpha hanya dapat berisi karakter alfanumerik",
466470
},
471+
{
472+
ns: "TestStringTags.Alphaspace",
473+
expected: "Alphaspace hanya dapat berisi karakter alfabet dan spasi",
474+
},
475+
{
476+
ns: "TestStringTags.Alphanumspace",
477+
expected: "Alphanumspace hanya dapat berisi karakter alfanumerik dan spasi",
478+
},
467479
{
468480
ns: "TestStringTags.Alphanum",
469481
expected: "Alphanum hanya dapat berisi karakter alfanumerik",

0 commit comments

Comments
 (0)