github.com/go-email-validator/go-email-validator@v0.0.0-20230409163946-b8b9e6a0552e/pkg/ev/contains/contains.go (about) 1 package contains 2 3 import ( 4 "github.com/emirpasic/gods/sets" 5 ) 6 7 // InSet checks presence of value 8 type InSet interface { 9 Contains(value interface{}) bool 10 } 11 12 // NewSet instantiates InSet based on sets.Set 13 func NewSet(s sets.Set) InSet { 14 return setContains{s} 15 } 16 17 type setContains struct { 18 set sets.Set 19 } 20 21 func (s setContains) Contains(value interface{}) bool { 22 return s.set.Contains(value) 23 } 24 25 // FuncChecker checks presence of value 26 type FuncChecker func(value interface{}) bool 27 28 // NewFunc instantiates InSet, functions is used for checking 29 func NewFunc(f FuncChecker) InSet { 30 return funcContains{f} 31 } 32 33 type funcContains struct { 34 funcChecker FuncChecker 35 } 36 37 func (f funcContains) Contains(value interface{}) bool { 38 return f.funcChecker(value) 39 }