validation

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ObjectNameRegex is the regular expression used to validate the object IDs.
	ObjectNameRegex = regexp.MustCompile("^[a-zA-Z0-9/_-]{2,64}$")

	// RelationNameRegex is the regular expression used to validate the names of relations.
	RelationNameRegex = regexp.MustCompile(fmt.Sprintf(`^(\.\.\.|%s)$`, identifier))

	// NamespaceRegex is the regular expression used to validate namespace names.
	NamespaceRegex = regexp.MustCompile(fmt.Sprintf("^(%s/)?%s$", identifier, identifier))

	// NamespaceRegex is the regular expression used to validate namespace names
	// that require tenant slugs.
	NamespaceWithTenantRegex = regexp.MustCompile(fmt.Sprintf("^(%s)/(%s)$", identifier, identifier))

	ErrInvalidObjectName    = errors.New("invalid object name")
	ErrInvalidRelationName  = errors.New("invalid relation name")
	ErrInvalidNamespaceName = errors.New("invalid namespace name")
)

Functions

func NamespaceName

func NamespaceName(name string) error

NamespaceName validates that the string provided is a valid namespace name.

func NamespaceNameWithTenant

func NamespaceNameWithTenant(name string) error

NamespaceNameWithTenant validates that the string provided is a valid namespace name and contains a tenant component.

func ObjectName

func ObjectName(name string) error

ObjectName validates that the string provided is a valid object name.

func RelationName

func RelationName(name string) error

RelationName validates that the string provided is a valid relation name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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