operation

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownOperation = errors.New("unknown operation")

Functions

This section is empty.

Types

type Operation

type Operation string

Operation represents an JSON patch operation.

const (
	// RemoveOperation is an operation to remove the value at the target location.
	// Requires `path`.
	RemoveOperation Operation = "remove"
	// AddOperation add a value or array to an array at the target location.
	// Requires `path` and `value`. Target of the path must be an array.
	AddOperation Operation = "add"
	// ReplaceOperation replaces the value at the target location
	// with a new value. Requires `path` and `value`.
	ReplaceOperation Operation = "replace"
	// MoveOperation removes the value at a specified location and
	// adds it to the target location. Requires `from` and `path`.
	MoveOperation Operation = "move"
	// CopyOperation copies the value from a specified location to the
	// target location. Requires `from` and `path`.
	CopyOperation Operation = "copy"
)

func FromString

func FromString(operationString string) (*Operation, error)

FromString return operation that matches string or nil with error if no match.

type Path

type Path string

func (Path) Equal

func (p Path) Equal(comparePath Path) bool

Equal check if path is equal to given path. Single fields can be set to `*` for wildcard.

func (Path) Valid

func (p Path) Valid() bool

Valid check if given path is in valid format.

type Spec

type Spec struct {
	From      Path        `json:"from"`
	Path      Path        `json:"path"`
	Value     interface{} `json:"value"`
	Operation Operation   `json:"op"` //nolint:tagliatelle
}

Spec specify an path operation.

func (Spec) Valid

func (s Spec) Valid() bool

Valid check if operation is valid.

Jump to

Keyboard shortcuts

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