• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-playground / validator / 13687129122
74%
v8: 100%

Build:
Build:
LAST BUILD BRANCH: master
DEFAULT BRANCH: v8
Ran 05 Mar 2025 10:51PM UTC
Jobs 1
Files 33
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

05 Mar 2025 10:51PM UTC coverage: 74.466% (-0.4%) from 74.823%
13687129122

push

github

web-flow
Fix: Nil pointer dereference in Arabic translations (#1391)

## 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.

### Description
This PR fixes [Bug #1385]: Nil pointer dereference in Arabic
translations and adds comprehensive Arabic (ar) translations for the
go-playground/validator package. The implementation provides Arabic
error messages for all common validation tags, making the validator more
valuable to Arabic-speaking developers.

### Features
- Fixes nil pointer dereference bug in Arabic translations
- Complete Arabic translations for all standard validation tags
- Comprehensive test suite to verify translation accuracy
- Follows the same pattern as existing language translations
- Properly handles Arabic text direction and grammar

### Implementation Details
- The implementation follows the established pattern in the validator
package:
- Registers translations for each validation tag
- Provides appropriate Arabic phrasing for validation errors
- Handles parameter substitution in error messages
- Includes tests for all validation scenarios

### Testing
- A comprehensive test suite is included that verifies:
- Basic validations (required, email, etc.)
- Length validations (min, max, len)
- Comparison validations (lt, lte, gt, gte, eq, ne)
- Field comparison validations (eqfield, nefield, gtefield)
- Content validations (alpha, alphanum, contains, etc.)
- Special validations (oneof, datetime)
- All tests pass and confirm that the translations are correctly
applied.

### Usage Example
```go
validate := validator.New()
arabic := ar.New()
uni := ut.New(arabic, arabic)
trans, _ := uni.GetTranslator("ar")

// Register Arabic translations
ar.RegisterDefaultTranslations(validate, trans)

// Now validation errors will be in Arabic
err := validate.Struct(myStruct)
if err != nil {
    errs := err.(validator.ValidationErrors)
    for _, e := r... (continued)

284 of 390 new or added lines in 1 file covered. (72.82%)

102 existing lines in 1 file now uncovered.

14331 of 19245 relevant lines covered (74.47%)

76.29 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
106
57.8
-8.03% translations/ar/ar.go

Uncovered Existing Lines

Lines Coverage ∆ File
102
57.8
-8.03% translations/ar/ar.go
Jobs
ID Job ID Ran Files Coverage
1 13687129122.1 05 Mar 2025 10:51PM UTC 33
74.47
GitHub Action Run
Source Files on build 13687129122
  • Tree
  • List 33
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • bae7f6d3 on github
  • Prev Build on master (#13687059555)
  • Next Build on master (#13778465291)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc