mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
carddav: add matchType
This commit is contained in:
parent
38b729ad9c
commit
30977aac83
@ -77,7 +77,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (ft *filterTest) UnmarshalText(b []byte) error {
|
func (ft *filterTest) UnmarshalText(b []byte) error {
|
||||||
v := filterTest(string(b))
|
v := filterTest(b)
|
||||||
switch v {
|
switch v {
|
||||||
case filterAnyOf, filterAllOf:
|
case filterAnyOf, filterAllOf:
|
||||||
*ft = v
|
*ft = v
|
||||||
@ -100,11 +100,31 @@ type propFilter struct {
|
|||||||
|
|
||||||
// https://tools.ietf.org/html/rfc6352#section-10.5.4
|
// https://tools.ietf.org/html/rfc6352#section-10.5.4
|
||||||
type textMatch struct {
|
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 string `xml:"negate-condition,attr,omitempty"`
|
||||||
MatchType string `xml:"match-type,attr,omitempty"`
|
MatchType matchType `xml:"match-type,attr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type matchType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
matchEquals matchType = "equals"
|
||||||
|
matchContains matchType = "contains"
|
||||||
|
matchStartsWith matchType = "starts-with"
|
||||||
|
matchEndsWith matchType = "ends-with"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (mt *matchType) UnmarshalText(b []byte) error {
|
||||||
|
v := matchType(b)
|
||||||
|
switch v {
|
||||||
|
case matchEquals, matchContains, matchStartsWith, matchEndsWith:
|
||||||
|
*mt = v
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("carddav: invalid match type value: %q", v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://tools.ietf.org/html/rfc6352#section-10.5.2
|
// https://tools.ietf.org/html/rfc6352#section-10.5.2
|
||||||
|
Loading…
Reference in New Issue
Block a user