-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathor.go
More file actions
32 lines (25 loc) · 755 Bytes
/
or.go
File metadata and controls
32 lines (25 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package comver
import "strings"
//nolint:godox
// TODO: Make Or to be []Constrainter so that we can nest Or
// Or represents a logical OR operation between multiple [CeilingFloorConstrainter] instances.
// The zero value for Or is a [match none] constraint which could never be satisfied.
//
// [match none]: https://github.com/composer/semver/blob/main/src/Constraint/MatchNoneConstraint.php
type Or []CeilingFloorConstrainter
// Check reports whether a [Version] satisfies the constraint.
func (o Or) Check(v Version) bool {
for i := range o {
if o[i].Check(v) {
return true
}
}
return false
}
func (o Or) String() string {
ss := make([]string, len(o))
for i := range o {
ss[i] = o[i].String()
}
return strings.Join(ss, " || ")
}