mirror of
https://github.com/safing/portbase
synced 2025-09-02 02:29:59 +00:00
33 lines
571 B
Go
33 lines
571 B
Go
package query
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type existsCondition struct {
|
|
key string
|
|
operator uint8
|
|
}
|
|
|
|
func newExistsCondition(key string, operator uint8) *existsCondition {
|
|
return &existsCondition{
|
|
key: key,
|
|
operator: operator,
|
|
}
|
|
}
|
|
|
|
func (c *existsCondition) complies(f Fetcher) bool {
|
|
return f.Exists(c.key)
|
|
}
|
|
|
|
func (c *existsCondition) check() error {
|
|
if c.operator == errorPresent {
|
|
return errors.New(c.key)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *existsCondition) string() string {
|
|
return fmt.Sprintf("%s %s", escapeString(c.key), getOpName(c.operator))
|
|
}
|