Skip to content

Fix length check on dns_rfc1035_label tag #1214

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
870ae2f
Fix length check on dns_rfc1035_label tag
KimNorgaard Jan 12, 2024
7e50791
Update errors.go (#975)
maltsev25 Jan 14, 2024
2ded414
Add translation of requiredXXX and excludedXXX in English/Chinese/Chi…
violin0622 Jan 14, 2024
1b32f6c
Update README.md
Jan 14, 2024
f3a010b
Update all library dependencies (#1222)
Feb 11, 2024
c8b5e6e
Update README.md
Feb 11, 2024
4d57a6d
Resolving "Validating unexported fields #417" (#1234)
nikolaianohyn Mar 2, 2024
85cbbca
update private field opt-in comment
Mar 2, 2024
a27ee91
add go 1.22 to ci build tests
Mar 2, 2024
b0c562e
update ci actions versions
Mar 2, 2024
9b241dc
Fix ULID should case-insensitive (#1258)
akayj Apr 30, 2024
0e13942
feat: add base32 validator tag (#1253)
jamesatkin-myndup Apr 30, 2024
9450b12
Add EU countries validator (#1252)
masv3971 Apr 30, 2024
b3fd8ed
Update README.md
Apr 30, 2024
e00b3dc
MongoDB validator improved (#1196)
pixel365 Jun 1, 2024
cd151f2
change codes bool value to struct{} (#1270)
nar10z Jun 1, 2024
c6d7092
Fix grammar issues in comments, tests, field names (#1262)
alexandear Jun 1, 2024
3555a94
Make docs for required more explicit regarding boolean values (#1261)
alexongh Jun 1, 2024
dcb8df9
Fix Japanese translation of max-items, lt-items and lte-items error (…
Tomoki108 Jun 1, 2024
0d9c588
chore: fix some comments (#1242)
pavedroad Jun 1, 2024
242afaa
Polish language support (#1217)
thinkofher Jun 1, 2024
042cd54
Update README.md
Jun 1, 2024
d90f7af
Lazily initialize regexes to speed up `init()` (#1277)
kylecarbs Jun 12, 2024
5bb5102
Add Ukrainian translation (#1275)
jhekasoft Jun 12, 2024
ea32634
Update README.md
Jun 12, 2024
681fa43
fix(#1310): fix excluded_if for pointers (#1313)
ganeshdipdumbare Sep 9, 2024
c958d0e
Update README.md
Sep 9, 2024
791d743
fix: cron validation support for star step value (#1302)
cgetzen Nov 16, 2024
375630e
doc(oneof): mention 'enum' (#1326)
Crocmagnon Nov 16, 2024
51289fa
Add oneofci validator (oneof case insensitive) (#1321)
miscalibrated Nov 16, 2024
acc69b5
feat: add validator for numeric ports (#1294)
nodivbyzero Nov 16, 2024
3a975b6
Update README.md
Nov 16, 2024
260dac6
Update README.md
Nov 16, 2024
1201a2b
MSGV additions (#1361)
deankarn Jan 13, 2025
f4897d2
Fix postcode_iso3166_alpha2_field validation (#1359)
ddevcap Feb 3, 2025
93ad448
Update README to replace the Travis CI badge with a GitHub Actions ba…
nodivbyzero Feb 10, 2025
e4bc1bc
chore: using errors.As instead of type assertion (#1346)
fatelei Feb 12, 2025
c392efe
Fix/remove issue template md (#1375)
ganeshdipdumbare Feb 14, 2025
11a6728
feat: Add support for omitting empty and zero values in validation (i…
zeewell Feb 15, 2025
ac03fe5
Update README.md
deankarn Feb 15, 2025
32b0a50
Use correct pointer in errors.As(). Fix "panic: errors: *target must …
antonsoroko Feb 18, 2025
5e26dce
Create dependabot (#1373)
nodivbyzero Feb 18, 2025
b7b399b
Bump golangci/golangci-lint-action from 4 to 6 (#1381)
dependabot[bot] Feb 18, 2025
311dd58
Bump golang.org/x/text from 0.21.0 to 0.22.0 (#1383)
dependabot[bot] Feb 19, 2025
6c73ec9
Bump golang.org/x/crypto from 0.32.0 to 0.33.0 (#1382)
dependabot[bot] Feb 19, 2025
a57419b
feat(translations): improve Indonesian translations and add tests (#1…
fathiraz Feb 20, 2025
d723ea5
Fix time.Duration translation error (#1154)
nodivbyzero Feb 22, 2025
4554f19
Update Project Status button (#1380)
nodivbyzero Feb 24, 2025
b823ecf
Remove gitter.im link from README.md (#1366)
nodivbyzero Feb 25, 2025
483a67b
Docs: fix `Base64RawURL` usage (#1336)
196Ikuchil Feb 25, 2025
5664ee2
Merge branch 'master' into fix-rfc-1035-label-length-check
KimNorgaard Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions baked_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@ func isEqIgnoreCase(fl FieldLevel) bool {
param := fl.Param()

switch field.Kind() {

case reflect.String:
return strings.EqualFold(field.String(), param)
}
Expand Down Expand Up @@ -1606,7 +1605,6 @@ func isImage(fl FieldLevel) bool {
case reflect.String:
filePath := field.String()
fileInfo, err := os.Stat(filePath)

if err != nil {
return false
}
Expand Down Expand Up @@ -1635,7 +1633,6 @@ func isImage(fl FieldLevel) bool {

// isFilePath is the validation function for validating if the current field's value is a valid file path.
func isFilePath(fl FieldLevel) bool {

var exists bool
var err error

Expand Down Expand Up @@ -2227,7 +2224,6 @@ func isGt(fl FieldLevel) bool {
case reflect.Struct:

if field.Type().ConvertibleTo(timeType) {

return field.Convert(timeType).Interface().(time.Time).After(time.Now().UTC())
}
}
Expand Down Expand Up @@ -2464,7 +2460,6 @@ func isLt(fl FieldLevel) bool {
case reflect.Struct:

if field.Type().ConvertibleTo(timeType) {

return field.Convert(timeType).Interface().(time.Time).Before(time.Now().UTC())
}
}
Expand Down Expand Up @@ -2644,7 +2639,6 @@ func isDir(fl FieldLevel) bool {

// isDirPath is the validation function for validating if the current field's value is a valid directory.
func isDirPath(fl FieldLevel) bool {

var exists bool
var err error

Expand Down Expand Up @@ -2957,6 +2951,12 @@ func isCveFormat(fl FieldLevel) bool {
// a valid dns RFC 1035 label, defined in RFC 1035.
func isDnsRFC1035LabelFormat(fl FieldLevel) bool {
val := fl.Field().String()

size := len(val)
if size > 63 {
return false
}

return dnsRegexRFC1035Label().MatchString(val)
}

Expand Down
2 changes: 1 addition & 1 deletion regexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const (
splitParamsRegexString = `'[^']*'|\S+`
bicRegexString = `^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$`
semverRegexString = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$` // numbered capture groups https://semver.org/
dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9]){0,62}$"
dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9])?$"
cveRegexString = `^CVE-(1999|2\d{3})-(0[^0]\d{2}|0\d[^0]\d{1}|0\d{2}[^0]|[1-9]{1}\d{3,})$` // CVE Format Id https://cve.mitre.org/cve/identifiers/syntaxchange.html
mongodbIdRegexString = "^[a-f\\d]{24}$"
mongodbConnStringRegexString = "^mongodb(\\+srv)?:\\/\\/(([a-zA-Z\\d]+):([a-zA-Z\\d$:\\/?#\\[\\]@]+)@)?(([a-z\\d.-]+)(:[\\d]+)?)((,(([a-z\\d.-]+)(:(\\d+))?))*)?(\\/[a-zA-Z-_]{1,64})?(\\?(([a-zA-Z]+)=([a-zA-Z\\d]+))(&(([a-zA-Z\\d]+)=([a-zA-Z\\d]+))?)*)?$"
Expand Down
2 changes: 2 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13243,6 +13243,8 @@ func TestRFC1035LabelFormatValidation(t *testing.T) {
{"ABC-ABC", "dns_rfc1035_label", false},
{"123-abc", "dns_rfc1035_label", false},
{"", "dns_rfc1035_label", false},
{"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk", "dns_rfc1035_label", true},
{"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl", "dns_rfc1035_label", false},
}

validate := New()
Expand Down