nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: go-playground/validator
Pull request #657 (2020-09-01 13:23:18)

Validate tag omitempty, only base on field value
Fixes validation of tag omitempty, base on the field value #654.

**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.

Change Details:

- Validate the tag omitempty, only base on the field value.


@go-playground/admins


Patch:
diff --git a/validator.go b/validator.go
index 342e72e..f097f39 100644
--- a/validator.go
+++ b/validator.go
@@ -249,7 +249,7 @@ OUTER:
 			v.cf = cf
 			v.ct = ct
 
-			if !v.fldIsPointer && !hasValue(v) {
+			if !hasValue(v) {
 				return
 			}
 


Test patch:
diff --git a/validator_test.go b/validator_test.go
index e76a3cd..a26dc75 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -8858,6 +8858,16 @@ func TestRequiredWithout(t *testing.T) {
 	AssertError(t, errs, "Field6", "Field6", "Field6", "Field6", "required_without")
 	AssertError(t, errs, "Field7", "Field7", "Field7", "Field7", "required_without")
 	AssertError(t, errs, "Field8", "Field8", "Field8", "Field8", "required_without")
+
+	test3 := struct {
+		Field1 *string `validate:"required_without=Field2,omitempty,min=1" json:"field_1"`
+		Field2 *string `validate:"required_without=Field1,omitempty,min=1" json:"field_2"`
+	}{
+		Field1: &fieldVal,
+	}
+
+	errs = validate.Struct(&test3)
+	Equal(t, errs, nil)
 }
 
 func TestRequiredWithoutAll(t *testing.T) {
Repository: go-playground/validator
Pull request #911 (2022-03-12 04:08:01)

Result is wrong while there are multiple group of OR operators #910
## Fixes Or Enhances
Fix bug #910

```go
type T struct {
   Value int `validate:"eq=1|gte=5,eq=1|lt=7"`
}

t := T{8}
```

should failed the test

**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

coveralls: 
[![Coverage Status](https://coveralls.io/builds/47301005/badge)](https://coveralls.io/builds/47301005)

Coverage decreased (-0.02%) to 75.12% when pulling **6d2313895315a0404d08502bbde8253fec4d006d on XIELongDragon:master** into **58d5778b183e89cc374ca4ebbf06da1eed088a63 on go-playground:master**.


Patch:
diff --git a/validator.go b/validator.go
index 2a4fad0..c2e0358 100644
--- a/validator.go
+++ b/validator.go
@@ -355,6 +355,10 @@ OUTER:
 				v.ct = ct
 
 				if ct.fn(ctx, v) {
+					if ct.isBlockEnd {
+						ct = ct.next
+						continue OUTER
+					}
 
 					// drain rest of the 'or' values, then continue or leave
 					for {
@@ -368,6 +372,11 @@ OUTER:
 						if ct.typeof != typeOr {
 							continue OUTER
 						}
+
+						if ct.isBlockEnd {
+							ct = ct.next
+							continue OUTER
+						}
 					}
 				}
 


Test patch:
diff --git a/validator_test.go b/validator_test.go
index 6aee559..b7bcec2 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -11790,3 +11790,27 @@ func TestCreditCardFormatValidation(t *testing.T) {
 		}
 	}
 }
+
+func TestMultiOrOperatorGroup(t *testing.T) {
+ 	tests := []struct {
+ 		Value    int `validate:"eq=1|gte=5,eq=1|lt=7"`
+ 		expected bool
+ 	}{
+ 		{1, true}, {2, false}, {5, true}, {6, true}, {8, false},
+ 	}
+
+ 	validate := New()
+
+ 	for i, test := range tests {
+ 		errs := validate.Struct(test)
+ 		if test.expected {
+ 			if !IsEqual(errs, nil) {
+ 				t.Fatalf("Index: %d multi_group_of_OR_operators failed Error: %s", i, errs)
+ 			}
+ 		} else {
+ 			if IsEqual(errs, nil) {
+ 				t.Fatalf("Index: %d multi_group_of_OR_operators should have errs", i)
+ 			}
+ 		}
+ 	}
+ }
Repository: go-playground/validator
Pull request #945 (2022-05-14 19:29:52)

feat(BREAKING): Change CIDRIPv4 validation
## Summary

- Mentions #909 
- Disable validation of cidripv4 when ip is not the begining of the block
- My linter just added some `go fmt` I guess

## Fixes Or Enhances

- [x] Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

coveralls: 
[![Coverage Status](https://coveralls.io/builds/49122893/badge)](https://coveralls.io/builds/49122893)

Coverage remained the same at 74.177% when pulling **554e1a11c55ae18645c3059e898e8488bc39b608 on martinlehoux:master** into **9e2ea4038020b5c7e3802a21cfa4e3afcfdcd276 on go-playground:master**.

martinlehoux: Hi @deankarn , is there anything I can do to push this forward?
martinlehoux: Hi @deankarn is there anyway to have a status on this one? So I know if I take the time to rebase, or if this change is not useful 
deankarn: Hey @martinlehoux sorry for letting this one slip through the cracks.

yes I will try to merge tomorrow.

Patch:
diff --git a/baked_in.go b/baked_in.go
index cc92b78..0b62330 100644
--- a/baked_in.go
+++ b/baked_in.go
@@ -373,9 +373,9 @@ func isMAC(fl FieldLevel) bool {
 
 // isCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address.
 func isCIDRv4(fl FieldLevel) bool {
-	ip, _, err := net.ParseCIDR(fl.Field().String())
+	ip, net, err := net.ParseCIDR(fl.Field().String())
 
-	return err == nil && ip.To4() != nil
+	return err == nil && ip.To4() != nil && net.IP.Equal(ip)
 }
 
 // isCIDRv6 is the validation function for validating if the field's value is a valid v6 CIDR address.


Test patch:
diff --git a/validator_test.go b/validator_test.go
index 09ff1df..230ab61 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -2575,19 +2575,26 @@ func TestCIDRv4Validation(t *testing.T) {
 		param    string
 		expected bool
 	}{
-		{"10.0.0.0/0", true},
-		{"10.0.0.1/8", true},
-		{"172.16.0.1/16", true},
-		{"192.168.0.1/24", true},
-		{"192.168.255.254/24", true},
+		{"0.0.0.0/0", true},
+		{"10.0.0.0/0", false},
+		{"10.0.0.0/8", true},
+		{"10.0.0.1/8", false},
+		{"172.16.0.0/16", true},
+		{"172.16.0.1/16", false},
+		{"192.168.0.0/24", true},
+		{"192.168.0.1/24", false},
+		{"192.168.255.0/24", true},
+		{"192.168.255.254/24", false},
 		{"192.168.255.254/48", false},
 		{"192.168.255.256/24", false},
-		{"172.16.255.254/16", true},
+		{"172.16.0.0/16", true},
+		{"172.16.255.254/16", false},
 		{"172.16.256.255/16", false},
 		{"2001:cdba:0000:0000:0000:0000:3257:9652/64", false},
 		{"2001:cdba:0000:0000:0000:0000:3257:9652/256", false},
 		{"2001:cdba:0:0:0:0:3257:9652/32", false},
 		{"2001:cdba::3257:9652/16", false},
+		{"172.56.1.0/16", false},
 	}
 
 	validate := New()