-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathcondition_boolean.go
More file actions
27 lines (21 loc) · 776 Bytes
/
Copy pathcondition_boolean.go
File metadata and controls
27 lines (21 loc) · 776 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
package ladon
import "context"
/*
BooleanCondition is used to determine if a boolean context matches an expected
boolean condition.
BooleanCondition implements the ladon.Condition interface.
See https://github.com/ory/ladon/blob/master/condition.go
*/
type BooleanCondition struct {
BooleanValue bool `json:"value"`
}
// GetName returns the name of the BooleanCondition
func (c *BooleanCondition) GetName() string {
return "BooleanCondition"
}
// Fulfills determines if the BooleanCondition is fulfilled.
// The BooleanCondition is fulfilled if the provided boolean value matches the conditions boolean value.
func (c *BooleanCondition) Fulfills(ctx context.Context, value interface{}, _ *Request) bool {
val, ok := value.(bool)
return ok && val == c.BooleanValue
}