mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
31 lines
524 B
Go
31 lines
524 B
Go
package query
|
|
|
|
// And combines multiple conditions with a logical _AND_ operator.
|
|
func And(conditions ...Condition) Condition {
|
|
return &andCond{
|
|
conditions: conditions,
|
|
}
|
|
}
|
|
|
|
type andCond struct {
|
|
conditions []Condition
|
|
}
|
|
|
|
func (c *andCond) complies(f Fetcher) bool {
|
|
for _, cond := range c.conditions {
|
|
if !cond.complies(f) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (c *andCond) check() (err error) {
|
|
for _, cond := range c.conditions {
|
|
err = cond.check()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|