Documentation
¶
Overview ¶
Package Specify is a library that is intended to provide a layer of abstraction using the Specification Pattern to allow for programticly defining conditions and allow for chaining.
Index ¶
- type Condition
- func And[T any](a, b Condition[T], conditions ...Condition[T]) Condition[T]
- func NewCondition[T any](check func(input T) (bool, error)) Condition[T]
- func Not[T any](cond Condition[T]) Condition[T]
- func Or[T any](a, b Condition[T], conditions ...Condition[T]) Condition[T]
- func Xor[T any](a, b Condition[T], more ...Condition[T]) Condition[T]
- type ConditionAnd
- type ConditionFunc
- type ConditionOr
- type ConditionXor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition[T any] interface { // Check evaluates the defined condition against the provided value [T], // in the event an error is returned, the result value should be ignored. Check(input T) (result bool, err error) }
Condition provides an abstraction to define conditions programatically that will be lazily evaluated once once it is checked.
func And ¶
And lazily performs the logical and which will stop once false result is returned from a provided condition.
func NewCondition ¶ added in v0.0.3
type ConditionAnd ¶
type ConditionAnd[T any] interface { Condition[T] // And is an alias for `specify.And(this, b, others...)` And(b Condition[T], others ...Condition[T]) Condition[T] }
ConditionAnd is an extension to condition to allow for natural reading condition statements when using `ConditionFunc`.
type ConditionFunc ¶
ConditionFunc implements the Condition[T] type and allows for simplified lambda abstractions.
func (ConditionFunc[T]) And ¶
func (cond ConditionFunc[T]) And(b Condition[T], others ...Condition[T]) Condition[T]
func (ConditionFunc[T]) Check ¶
func (cond ConditionFunc[T]) Check(input T) (bool, error)
func (ConditionFunc[T]) Or ¶
func (cond ConditionFunc[T]) Or(b Condition[T], others ...Condition[T]) Condition[T]
func (ConditionFunc[T]) Xor ¶
func (cond ConditionFunc[T]) Xor(b Condition[T]) Condition[T]
type ConditionOr ¶
type ConditionOr[T any] interface { Condition[T] // Or is an alias for `specify.Or(this, b, others ...)` Or(b Condition[T], others ...Condition[T]) Condition[T] }
ConditionOr is an extension to condition to allow for natural reading condition statements when using `ConditionFunc`.