go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.06k stars 1.29k forks source link

en translation issue: "must contain at maximum X items" #1249

Open mila-rodriguez-netapp opened 3 months ago

mila-rodriguez-netapp commented 3 months ago

Package version eg. v9, v10:

v10

github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.19.0

Issue, Question or Enhancement:

The default en translations for max have a strange construct (possibly a typo) for slices.

Expected:

{0} must contain maximum {1} items

Actual:

{0} must contain at maximum {1} items

Possibly this is attempting {0} must contain a maximum {1} items or {0} must contain at most {1} items. Not sure what the intent is, but the actual isn't right..

Code sample, to showcase or reproduce:

type Example struct {
    URIs []string `json:"uris" validate:"required,max=5,dive,uri"
}

Hook up the default en translations and you'll get URIs must contain at maximum 5 items

mila-rodriguez-netapp commented 3 months ago

Since the equivalent with min resolves to {0} must contain at least {1} items, I'm pretty sure the intent here was to have {0} must contain at most {1} items as its max counterpart.