Skip to content

Commit e06a79e

Browse files
committed
lower case
1 parent 9bb59e2 commit e06a79e

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

openapiart/common.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ func validationResult() error {
164164
func validateMac(mac string) error {
165165
macSlice := strings.Split(mac, ":")
166166
if len(macSlice) != 6 {
167-
return fmt.Errorf(fmt.Sprintf("Invalid Mac address %s", mac))
167+
return fmt.Errorf(fmt.Sprintf("invalid mac address %s", mac))
168168
}
169169
octInd := []string{"0th", "1st", "2nd", "3rd", "4th", "5th"}
170170
for ind, val := range macSlice {
171171
num, err := strconv.ParseUint(val, 16, 32)
172172
if err != nil || num > 255 {
173-
return fmt.Errorf(fmt.Sprintf("Invalid Mac address at %s octet in %s mac", octInd[ind], mac))
173+
return fmt.Errorf(fmt.Sprintf("invalid mac address at %s octet in %s mac", octInd[ind], mac))
174174
}
175175
}
176176
return nil
@@ -179,13 +179,13 @@ func validateMac(mac string) error {
179179
func validateIpv4(ip string) error {
180180
ipSlice := strings.Split(ip, ".")
181181
if len(ipSlice) != 4 {
182-
return fmt.Errorf(fmt.Sprintf("Invalid Ipv4 address %s", ip))
182+
return fmt.Errorf(fmt.Sprintf("invalid ipv4 address %s", ip))
183183
}
184184
octInd := []string{"1st", "2nd", "3rd", "4th"}
185185
for ind, val := range ipSlice {
186186
num, err := strconv.ParseUint(val, 10, 32)
187187
if err != nil || num > 255 {
188-
return fmt.Errorf(fmt.Sprintf("Invalid Ipv4 address at %s octet in %s ipv4", octInd[ind], ip))
188+
return fmt.Errorf(fmt.Sprintf("invalid ipv4 address at %s octet in %s ipv4", octInd[ind], ip))
189189
}
190190
}
191191
return nil
@@ -196,13 +196,13 @@ func validateIpv6(ip string) error {
196196
if strings.Count(ip, " ") > 0 || strings.Count(ip, ":") > 7 ||
197197
strings.Count(ip, "::") > 1 || strings.Count(ip, ":::") > 0 ||
198198
strings.Count(ip, ":") == 0 {
199-
return fmt.Errorf(fmt.Sprintf("Invalid ipv6 address %s", ip))
199+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address %s", ip))
200200
}
201201
if (string(ip[0]) == ":" && string(ip[:2]) != "::") || (string(ip[len(ip)-1]) == ":" && string(ip[len(ip)-2:]) != "::") {
202-
return fmt.Errorf(fmt.Sprintf("Invalid ipv6 address %s", ip))
202+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address %s", ip))
203203
}
204204
if strings.Count(ip, "::") == 0 && strings.Count(ip, ":") != 7 {
205-
return fmt.Errorf(fmt.Sprintf("Invalid ipv6 address %s", ip))
205+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address %s", ip))
206206
}
207207
if ip == "::" {
208208
return nil
@@ -224,7 +224,7 @@ func validateIpv6(ip string) error {
224224
for ind, val := range ipSlice {
225225
num, err := strconv.ParseUint(val, 16, 64)
226226
if err != nil || num > 65535 {
227-
return fmt.Errorf(fmt.Sprintf("Invalid Ipv6 address at %s octet in %s ipv6", octInd[ind], ip))
227+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address at %s octet in %s ipv6", octInd[ind], ip))
228228
}
229229
}
230230

@@ -234,7 +234,7 @@ func validateIpv6(ip string) error {
234234
func validateHex(hex string) error {
235235
matched, err := regexp.MatchString(`^[0-9a-fA-F]+$|^0[x|X][0-9a-fA-F]+$`, hex)
236236
if err != nil || !matched {
237-
return fmt.Errorf(fmt.Sprintf("Invalid hex value %s", hex))
237+
return fmt.Errorf(fmt.Sprintf("invalid hex value %s", hex))
238238
}
239239
return nil
240240
}
@@ -253,7 +253,7 @@ func validateSlice(valSlice []string, sliceType string) error {
253253
} else if sliceType == "hex" {
254254
err = validateHex(val)
255255
} else {
256-
return fmt.Errorf(fmt.Sprintf("Invalid slice type received <%s>", sliceType))
256+
return fmt.Errorf(fmt.Sprintf("invalid slice type received <%s>", sliceType))
257257
}
258258

259259
if err != nil {
@@ -262,7 +262,7 @@ func validateSlice(valSlice []string, sliceType string) error {
262262
}
263263
if len(indices) > 0 {
264264
return fmt.Errorf(
265-
fmt.Sprintf("Invalid %s addresses at indices %s", sliceType, strings.Join(indices, ",")),
265+
fmt.Sprintf("invalid %s addresses at indices %s", sliceType, strings.Join(indices, ",")),
266266
)
267267
}
268268
return nil

pkg/common.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ func validationResult() error {
166166
func validateMac(mac string) error {
167167
macSlice := strings.Split(mac, ":")
168168
if len(macSlice) != 6 {
169-
return fmt.Errorf(fmt.Sprintf("Invalid Mac address %s", mac))
169+
return fmt.Errorf(fmt.Sprintf("invalid mac address %s", mac))
170170
}
171171
octInd := []string{"0th", "1st", "2nd", "3rd", "4th", "5th"}
172172
for ind, val := range macSlice {
173173
num, err := strconv.ParseUint(val, 16, 32)
174174
if err != nil || num > 255 {
175-
return fmt.Errorf(fmt.Sprintf("Invalid Mac address at %s octet in %s mac", octInd[ind], mac))
175+
return fmt.Errorf(fmt.Sprintf("invalid mac address at %s octet in %s mac", octInd[ind], mac))
176176
}
177177
}
178178
return nil
@@ -181,13 +181,13 @@ func validateMac(mac string) error {
181181
func validateIpv4(ip string) error {
182182
ipSlice := strings.Split(ip, ".")
183183
if len(ipSlice) != 4 {
184-
return fmt.Errorf(fmt.Sprintf("Invalid Ipv4 address %s", ip))
184+
return fmt.Errorf(fmt.Sprintf("invalid ipv4 address %s", ip))
185185
}
186186
octInd := []string{"1st", "2nd", "3rd", "4th"}
187187
for ind, val := range ipSlice {
188188
num, err := strconv.ParseUint(val, 10, 32)
189189
if err != nil || num > 255 {
190-
return fmt.Errorf(fmt.Sprintf("Invalid Ipv4 address at %s octet in %s ipv4", octInd[ind], ip))
190+
return fmt.Errorf(fmt.Sprintf("invalid ipv4 address at %s octet in %s ipv4", octInd[ind], ip))
191191
}
192192
}
193193
return nil
@@ -198,13 +198,13 @@ func validateIpv6(ip string) error {
198198
if strings.Count(ip, " ") > 0 || strings.Count(ip, ":") > 7 ||
199199
strings.Count(ip, "::") > 1 || strings.Count(ip, ":::") > 0 ||
200200
strings.Count(ip, ":") == 0 {
201-
return fmt.Errorf(fmt.Sprintf("Invalid ipv6 address %s", ip))
201+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address %s", ip))
202202
}
203203
if (string(ip[0]) == ":" && string(ip[:2]) != "::") || (string(ip[len(ip)-1]) == ":" && string(ip[len(ip)-2:]) != "::") {
204-
return fmt.Errorf(fmt.Sprintf("Invalid ipv6 address %s", ip))
204+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address %s", ip))
205205
}
206206
if strings.Count(ip, "::") == 0 && strings.Count(ip, ":") != 7 {
207-
return fmt.Errorf(fmt.Sprintf("Invalid ipv6 address %s", ip))
207+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address %s", ip))
208208
}
209209
if ip == "::" {
210210
return nil
@@ -226,7 +226,7 @@ func validateIpv6(ip string) error {
226226
for ind, val := range ipSlice {
227227
num, err := strconv.ParseUint(val, 16, 64)
228228
if err != nil || num > 65535 {
229-
return fmt.Errorf(fmt.Sprintf("Invalid Ipv6 address at %s octet in %s ipv6", octInd[ind], ip))
229+
return fmt.Errorf(fmt.Sprintf("invalid ipv6 address at %s octet in %s ipv6", octInd[ind], ip))
230230
}
231231
}
232232

@@ -236,7 +236,7 @@ func validateIpv6(ip string) error {
236236
func validateHex(hex string) error {
237237
matched, err := regexp.MatchString(`^[0-9a-fA-F]+$|^0[x|X][0-9a-fA-F]+$`, hex)
238238
if err != nil || !matched {
239-
return fmt.Errorf(fmt.Sprintf("Invalid hex value %s", hex))
239+
return fmt.Errorf(fmt.Sprintf("invalid hex value %s", hex))
240240
}
241241
return nil
242242
}
@@ -255,7 +255,7 @@ func validateSlice(valSlice []string, sliceType string) error {
255255
} else if sliceType == "hex" {
256256
err = validateHex(val)
257257
} else {
258-
return fmt.Errorf(fmt.Sprintf("Invalid slice type received <%s>", sliceType))
258+
return fmt.Errorf(fmt.Sprintf("invalid slice type received <%s>", sliceType))
259259
}
260260

261261
if err != nil {
@@ -264,7 +264,7 @@ func validateSlice(valSlice []string, sliceType string) error {
264264
}
265265
if len(indices) > 0 {
266266
return fmt.Errorf(
267-
fmt.Sprintf("Invalid %s addresses at indices %s", sliceType, strings.Join(indices, ",")),
267+
fmt.Sprintf("invalid %s addresses at indices %s", sliceType, strings.Join(indices, ",")),
268268
)
269269
}
270270
return nil

pkg/unit_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func TestBadMacValidation(t *testing.T) {
350350
macObj := config.MacPattern().Mac().SetValue(mac)
351351
err := macObj.Validate()
352352
if assert.Error(t, err) {
353-
assert.Contains(t, err.Error(), "Invalid Mac")
353+
assert.Contains(t, err.Error(), "invalid mac")
354354
}
355355
}
356356
}
@@ -418,7 +418,7 @@ func TestBadIpv4Validation(t *testing.T) {
418418
ipv4 := config.Ipv4Pattern().Ipv4().SetValue(ip)
419419
err := ipv4.Validate()
420420
if assert.Error(t, err) {
421-
assert.Contains(t, err.Error(), "Invalid Ipv4")
421+
assert.Contains(t, err.Error(), "invalid ipv4")
422422
}
423423
}
424424
}
@@ -429,7 +429,7 @@ func TestBadIpv4Values(t *testing.T) {
429429
ipv4 := config.Ipv4Pattern().Ipv4().SetValues(BadIpv4)
430430
err := ipv4.Validate()
431431
if assert.Error(t, err) {
432-
assert.Contains(t, err.Error(), "Invalid ipv4 addresses")
432+
assert.Contains(t, err.Error(), "invalid ipv4 addresses")
433433
}
434434
}
435435

@@ -441,7 +441,7 @@ func TestBadIpv4Increment(t *testing.T) {
441441
ipv4.SetCount(10)
442442
err := ipv4.Validate()
443443
if assert.Error(t, err) {
444-
assert.Contains(t, err.Error(), "Invalid Ipv4")
444+
assert.Contains(t, err.Error(), "invalid ipv4")
445445
}
446446
}
447447

@@ -453,7 +453,7 @@ func TestBadIpv4Decrement(t *testing.T) {
453453
ipv4.SetCount(10)
454454
err := ipv4.Validate()
455455
if assert.Error(t, err) {
456-
assert.Contains(t, err.Error(), "Invalid Ipv4")
456+
assert.Contains(t, err.Error(), "invalid ipv4")
457457
}
458458
}
459459

0 commit comments

Comments
 (0)