@@ -2,6 +2,7 @@ package parameter
22
33import (
44 standarderrs "errors"
5+
56 "github.com/charmbracelet/huh"
67 "github.com/shipengqi/golib/strutil"
78 "github.com/shipengqi/log"
@@ -114,12 +115,14 @@ func (c *Condition) Validate() []error {
114115}
115116
116117func (c * Condition ) Match () bool {
117- field , ok := c .fields [GetFiledKey (c .ParameterName )]
118+ key := GetFiledKey (c .ParameterName )
119+ log .Debugf ("math field condition: %s" , key )
120+ field , ok := c .fields [key ]
118121 if ! ok {
122+ log .Debugf ("cannot find field condition: %s" , key )
119123 return false
120124 }
121125 val := field .GetValue ()
122-
123126 if c .ValueEmpty != nil {
124127 return c .IsEmpty (* c .ValueEmpty , val )
125128 }
@@ -133,32 +136,39 @@ func (c *Condition) Match() bool {
133136 return c .Contains (val )
134137 }
135138 if c .ValueNotContains != nil {
139+ log .Debugf ("value not contains val: %v" , val )
136140 return c .NotContains (val )
137141 }
138142 return false
139143}
140144
141145func (c * Condition ) Equal (val interface {}) bool {
146+ log .Debugf ("%v contains match val: %v" , c .ValueEquals , val )
142147 return helpers .Equal (c .ValueEquals , val )
143148}
144149
145150func (c * Condition ) NotEqual (val interface {}) bool {
151+ log .Debugf ("%v not equals val: %v" , c .ValueNotEquals , val )
146152 return helpers .NotEqual (c .ValueNotEquals , val )
147153}
148154
149155func (c * Condition ) Contains (val interface {}) bool {
156+ log .Debugf ("%v contains val: %v" , val , c .ValueContains )
150157 return helpers .Contains (val , c .ValueContains )
151158}
152159
153160func (c * Condition ) NotContains (val interface {}) bool {
161+ log .Debugf ("%v not contains val: %v" , val , c .ValueContains )
154162 return helpers .NotContains (val , c .ValueNotContains )
155163}
156164
157165func (c * Condition ) IsEmpty (empty bool , val interface {}) bool {
158166 if empty && helpers .Empty (val ) {
167+ log .Debugf ("value is empty: %v" , val )
159168 return true
160169 }
161170 if ! empty && helpers .NotEmpty (val ) {
171+ log .Debugf ("value is not empty: %v" , val )
162172 return true
163173 }
164174 return false
0 commit comments