stringcondition

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: GPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package stringcondition exposes some common string condition implementations.

Index

Constants

View Source
const (
	// EqualsConditionKey is the sentinel key identifying a string == comparison.
	EqualsConditionKey = "equals"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EqualsCondition

type EqualsCondition struct {
	// Type stores the sentinel which represents the type of Condition implemented.
	Type string `json:"type" yaml:"type"`
	// Expected is the expected string value.
	Expected string `json:"expected,omitempty" yaml:"expected,omitempty"`
}

EqualsCondition is an implementation of the condition.Condition interface which evaluates string equality of a match against Expected. Although EqualsCondition is exported for serialization reasons, it is recommended to instantiate new instances of EqualsCondition using NewEqualsCondition.

func NewEqualsCondition

func NewEqualsCondition(expected string) *EqualsCondition

NewEqualsCondition creates an EqualsCondition.

func (EqualsCondition) Evaluate

func (e EqualsCondition) Evaluate(match string, regex *regexp.Regexp, matchIdx int) (bool, error)

Evaluate evaluates string equality for a match against Expected.

Jump to

Keyboard shortcuts

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