schema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schema

type Schema struct {
	JSONSchema *gojsonschema.Schema
	// contains filtered or unexported fields
}

Schema representation of properties in a JSON Schema format.

func FromBytes

func FromBytes(data []byte) (Schema, error)

FromBytes loads data into a JSON Schema that can be used for attribute validation.

func FromTypes

func FromTypes(types Types) (Schema, error)

FromTypes builds a JSON Schema from a key with an associated type. All keys provided will be considered required types in the schema when comparing sets of attributes.

func (Schema) Export

func (s Schema) Export() json.RawMessage

Export returns the json raw message.

func (Schema) Validate

func (s Schema) Validate(set model.AttributeSet) (bool, error)

Validate performs schema validation against the input attribute set.

type Type

type Type int

Type represent types for an attribute schema.

const (
	TypeInvalid Type = iota
	TypeNull
	TypeBool
	TypeNumber
	TypeInteger
	TypeString
)

func (Type) IsLike

func (t Type) IsLike() (model.Kind, error)

IsLike returns the model Kind that correlate to the schema Type.

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Schema Type into JSON format.

func (Type) String

func (t Type) String() string

String prints a string representation of the attribute kind.

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a JSON serialized type to the Schema Type

type Types

type Types map[string]Type

Types represent a schema Type mapped to a key of string type.

func (Types) Validate

func (t Types) Validate() error

Validate performs basic validation on a set of schema types.

Jump to

Keyboard shortcuts

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