specification

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

README

Specification Pattern implementation

Golang implementation of the Specification pattern using generics.

Usage example

Look at the ./example_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Specification

type Specification[T any] interface {
	Validate(*T) error
	Create(*T) error
}

func NewAndSpecification

func NewAndSpecification[T any](specs ...Specification[T]) Specification[T]

NewAndSpecification holds a slice of specifications and run each of them for Create and Validate methods. Fails if *any* specification failed.

func OrSpecification

func OrSpecification[T any](specs ...Specification[T]) Specification[T]

OrSpecification holds a slice of specifications and run each of them for Validate methods. Fails if *all* specifications failed.

func OrSpecificationWithCreate added in v1.1.0

func OrSpecificationWithCreate[T any](specs ...Specification[T]) Specification[T]

OrSpecificationWithCreate holds a slice of specifications and run each of them for Validate and Create methods. Fails if *all* specifications failed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL