schemagen

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 13 Imported by: 0

README

schematic

Generates model and validators by schema definition.

Install

Warning: go 1.16.6 required

$ go get -u github.com/funvit/schematic/...

How to use

See examples in /example.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrModelValidationError represents scope of model validation errors.
	ErrModelValidationError = scope_error.New("model validation error")
	// ErrModelFieldValidationError represents scope of model field validation errors.
	ErrModelFieldValidationError = scope_error.New("model field validation error")
)

Functions

func CamelToSnake

func CamelToSnake(s string) string

func MarshalJSON

func MarshalJSON(values map[string]interface{}, fields map[string]*field.Descriptor) ([]byte, error)

func SnakeToCamel

func SnakeToCamel(s string) string

func UnmarshalJSON

func UnmarshalJSON(b []byte, fields map[string]*field.Descriptor) (values map[string]interface{}, err error)

func ValidateModel

func ValidateModel(
	m interface{},
	fields map[string]*field.Descriptor,
	fieldErrors map[string]*scope_error.ScopeError,
) error

Types

type FieldsSet

type FieldsSet interface {
	Fields() []field.Field
}

type Schema

type Schema struct {
	FieldsSet
}

type SchemaConfig

type SchemaConfig struct {
	JSON bool
}

type SchemaConfiger

type SchemaConfiger interface {
	Model() SchemaConfig
}

Jump to

Keyboard shortcuts

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