specification

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package specification implements Specification tactical pattern. Validations are implemented as separate structs, each sharing a common interface that defines a single function. This allows us to utilize multiple, reusable validation rules independently. The `validUsers()` function remains unchanged while supporting different validation logic, leveraging polymorphism via injected specification dependencies. This approach adheres to the Open/Closed Principle — allowing behavior extension without modifying the existing code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run()

Types

type EmailValidation

type EmailValidation struct{}

func (EmailValidation) IsValid

func (ev EmailValidation) IsValid(entry *UserEntry) bool

type NameValidation

type NameValidation struct{}

func (NameValidation) IsValid

func (nv NameValidation) IsValid(entry *UserEntry) bool

type PhoneValidation

type PhoneValidation struct{}

PhoneValidation is a specific Specification implementation

func (PhoneValidation) IsValid

func (pv PhoneValidation) IsValid(entry *UserEntry) bool

type UserEntry

type UserEntry struct {
	// contains filtered or unexported fields
}

func (*UserEntry) String

func (u *UserEntry) String() string

type Validation

type Validation interface {
	IsValid(entry *UserEntry) bool
}

Validation is the common Specification interface

Jump to

Keyboard shortcuts

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