carddav: add negateCondition

This commit is contained in:
Simon Ser 2020-01-23 19:32:10 +01:00
parent 30977aac83
commit e56ab47c43
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -103,10 +103,31 @@ type textMatch struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav text-match"` XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav text-match"`
Text string `xml:",chardata"` Text string `xml:",chardata"`
Collation string `xml:"collation,attr,omitempty"` Collation string `xml:"collation,attr,omitempty"`
NegateCondition string `xml:"negate-condition,attr,omitempty"` NegateCondition negateCondition `xml:"negate-condition,attr,omitempty"`
MatchType matchType `xml:"match-type,attr,omitempty"` MatchType matchType `xml:"match-type,attr,omitempty"`
} }
type negateCondition bool
func (nc *negateCondition) UnmarshalText(b []byte) error {
switch s := string(b); s {
case "yes":
*nc = true
case "no":
*nc = false
default:
return fmt.Errorf("carddav: invalid negate-condition value: %q", s)
}
return nil
}
func (nc negateCondition) MarshalText() ([]byte, error) {
if nc {
return []byte("yes"), nil
}
return nil, nil
}
type matchType string type matchType string
const ( const (