text

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package text is the one rule for the text a client sends: it holds no control character other than a tab or a line break. PostgreSQL stores no U+0000 in text or jsonb and refuses the whole statement, so a request that carried one would be a 500 raised at will, and the other control characters mean nothing in a name, a note or a value and only trouble the terminals and logs that print them.

Index

Constants

View Source
const Code = "invalid_character"

Code is the stable name of the rule, as the violation's code and as the error's.

View Source
const MaxViolations = 20

MaxViolations bounds the violations one request names, so the answer stays small however much text is refused.

Variables

This section is empty.

Functions

func Allowed

func Allowed(s string) bool

Allowed reports whether s holds no control character other than a tab, a line feed or a carriage return.

func AllowedURL

func AllowedURL(u *url.URL) bool

AllowedURL reports whether the path of u and every name and value of its query, decoded, hold no refused character.

func Error

func Error(violations []apperrors.Violation) error

Error returns the invalid error that names violations, or nil for none.

func InJSON

func InJSON(body []byte) []apperrors.Violation

InJSON returns a violation for every string and member name of the JSON document body that holds a refused character, by JSON Pointer, in the order they appear. A body that is no JSON gives what was found before the fault: its own decoder refuses it, with its own words.

func InTree

func InTree(tree any) []apperrors.Violation

InTree returns a violation for every string and map key of a decoded document (maps of string to any, lists, strings) that holds a refused character, by JSON Pointer, in the order of the document, map members sorted by name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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