@@ -37,11 +37,27 @@ type FieldLevel interface {
3737 //
3838 // NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field
3939 // could not be retrieved because it didn't exist.
40+ //
41+ // Deprecated: Use GetStructFieldOK2() instead which also return if the value is nullable.
4042 GetStructFieldOK () (reflect.Value , reflect.Kind , bool )
4143
4244 // GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
4345 // the field and namespace allowing more extensibility for validators.
46+ //
47+ // Deprecated: Use GetStructFieldOKAdvanced2() instead which also return if the value is nullable.
4448 GetStructFieldOKAdvanced (val reflect.Value , namespace string ) (reflect.Value , reflect.Kind , bool )
49+
50+ // traverses the parent struct to retrieve a specific field denoted by the provided namespace
51+ // in the param and returns the field, field kind, if it's a nullable type and whether is was successful in retrieving
52+ // the field at all.
53+ //
54+ // NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field
55+ // could not be retrieved because it didn't exist.
56+ GetStructFieldOK2 () (reflect.Value , reflect.Kind , bool , bool )
57+
58+ // GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
59+ // the field and namespace allowing more extensibility for validators.
60+ GetStructFieldOKAdvanced2 (val reflect.Value , namespace string ) (reflect.Value , reflect.Kind , bool , bool )
4561}
4662
4763var _ FieldLevel = new (validate )
@@ -52,7 +68,7 @@ func (v *validate) Field() reflect.Value {
5268}
5369
5470// FieldName returns the field's name with the tag
55- // name takeing precedence over the fields actual name.
71+ // name taking precedence over the fields actual name.
5672func (v * validate ) FieldName () string {
5773 return v .cf .altName
5874}
@@ -68,12 +84,29 @@ func (v *validate) Param() string {
6884}
6985
7086// GetStructFieldOK returns Param returns param for validation against current field
87+ //
88+ // Deprecated: Use GetStructFieldOK2() instead which also return if the value is nullable.
7189func (v * validate ) GetStructFieldOK () (reflect.Value , reflect.Kind , bool ) {
72- return v .getStructFieldOKInternal (v .slflParent , v .ct .param )
90+ current , kind , _ , found := v .getStructFieldOKInternal (v .slflParent , v .ct .param )
91+ return current , kind , found
7392}
7493
7594// GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
7695// the field and namespace allowing more extensibility for validators.
96+ //
97+ // Deprecated: Use GetStructFieldOKAdvanced2() instead which also return if the value is nullable.
7798func (v * validate ) GetStructFieldOKAdvanced (val reflect.Value , namespace string ) (reflect.Value , reflect.Kind , bool ) {
99+ current , kind , _ , found := v .GetStructFieldOKAdvanced2 (val , namespace )
100+ return current , kind , found
101+ }
102+
103+ // GetStructFieldOK returns Param returns param for validation against current field
104+ func (v * validate ) GetStructFieldOK2 () (reflect.Value , reflect.Kind , bool , bool ) {
105+ return v .getStructFieldOKInternal (v .slflParent , v .ct .param )
106+ }
107+
108+ // GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
109+ // the field and namespace allowing more extensibility for validators.
110+ func (v * validate ) GetStructFieldOKAdvanced2 (val reflect.Value , namespace string ) (reflect.Value , reflect.Kind , bool , bool ) {
78111 return v .getStructFieldOKInternal (val , namespace )
79112}
0 commit comments