validator

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(dataType DataType, input []byte, opts ...ValidateOption) error

Validate validates the input provided in two phases:

  1. Validate the general structure of the resource or message based on the Type.
  2. Validate the specific structure of the resource or message based on the Kind.

A Kind can be optionally specified in order to fail early if the input's Kind does match what was provided. This is useful when the Kind is known ahead of time. If the Kind is not specified, validation will proceed to phase 2 using metadata.kind.

Note

Kind-specific schemas are lazily loaded the first time they are needed and then cached for future use.

Types

type DataType

type DataType string

DataType represents the type of data being validated e.g. resource or message

const (
	TypeResource DataType = "resource" // TypeResource represents tbdex resource
	TypeMessage  DataType = "message"  // TypeMessage represents tbdex message

)

type ValidateOption

type ValidateOption func(*validateOptions)

ValidateOption is a function that sets an option for the Validate function

func WithKind

func WithKind(kind string) ValidateOption

WithKind sets the kind option for the Validate function

Jump to

Keyboard shortcuts

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