@@ -42,8 +42,6 @@ type field struct {
42
42
HasPresence bool
43
43
// Whether validation should be ignored for certain conditions.
44
44
Ignore validate.Ignore
45
- // Zero is the default or zero-value for this value's type
46
- Zero protoreflect.Value
47
45
// Err stores if there was a compilation error constructing this evaluator. It is stored
48
46
// here so that it can be returned as part of validating this specific field.
49
47
Err error
@@ -59,13 +57,7 @@ func (f field) shouldIgnoreAlways() bool {
59
57
// This field is generally true for nullable fields or fields with the
60
58
// ignore_empty rule explicitly set.
61
59
func (f field ) shouldIgnoreEmpty () bool {
62
- return f .HasPresence || f .Ignore == validate .Ignore_IGNORE_IF_UNPOPULATED || f .Ignore == validate .Ignore_IGNORE_IF_DEFAULT_VALUE
63
- }
64
-
65
- // shouldIgnoreDefault returns whether this field should skip validation on its zero value,
66
- // including for fields which have field presence and are set to the zero value.
67
- func (f field ) shouldIgnoreDefault () bool {
68
- return f .HasPresence && f .Ignore == validate .Ignore_IGNORE_IF_DEFAULT_VALUE
60
+ return f .HasPresence || f .Ignore == validate .Ignore_IGNORE_IF_ZERO_VALUE
69
61
}
70
62
71
63
func (f field ) Evaluate (_ protoreflect.Message , val protoreflect.Value , cfg * validationConfig ) error {
@@ -103,11 +95,7 @@ func (f field) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig)
103
95
return nil
104
96
}
105
97
106
- val := msg .Get (f .Value .Descriptor )
107
- if f .shouldIgnoreDefault () && val .Equal (f .Zero ) {
108
- return nil
109
- }
110
- return f .Value .EvaluateField (msg , val , cfg , true )
98
+ return f .Value .EvaluateField (msg , msg .Get (f .Value .Descriptor ), cfg , true )
111
99
}
112
100
113
101
func (f field ) Tautology () bool {
0 commit comments