jsonassert

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package jsonassert implements the JSON property assertions shared by the packs: JSONPath lookups with Jayway semantics, and values that mean what they say (ADR 0014), compared with their types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandedProperties added in v0.3.0

func ExpandedProperties(doc string, t *core.Table, expand func(string) string) error

ExpandedProperties is Properties of values with the references in their strings expanded, after each value is read (core.Value.Expand): a reference is a string, whatever it expands to, and a failure shows it as written.

func IsNumber added in v0.3.0

func IsNumber(v core.Value) bool

IsNumber says the value is a number: `42`, `42L`, `1.5`.

func Properties

func Properties(doc string, t *core.Table, regex bool) error

Properties asserts each path/value row of t against the JSON document. A value is read by the rule every pack follows (core.ParseValue: `42` an integer, `"42"` the string, `null`, `undefined` for no such property) and compared with its type, strictly. With regex, values are Java regular expressions that must match the whole text of the value. All failing rows are reported together, like Hamcrest's allOf.

func Strict added in v0.3.0

func Strict(field, actual string, v core.Value) (same bool, hint string)

Strict says whether a value a database selected, as JSON, is v, type and all, as a check compares them: for a database whose own equality is looser than the rule's. hint says what to write when they differ only in type.

func StrictAt added in v0.3.0

func StrictAt(doc, path string, v core.Value) (same bool, hint string, err error)

StrictAt is Strict of the value at path in a JSON document.

func StrictStep added in v0.4.0

func StrictStep(field, actual string, v core.Value) (same bool, hint string)

StrictStep is Strict of a value in a step's own text, whose hint writes it in the step's quotes: `postcode is the string "53111": write '"53111"'`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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