Documentation
¶
Overview ¶
Package schema provides the `@schema NAME { Field Type `json:"..." validate:"..."` ... }` directive. The declaration lands in meta["schemas"]; the `:schema=NAME` modifier attaches the name to an atom so the strict-mode validation hook can find it.
Typical use:
@schema TestUser {
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"email"`
}
{ name: "Ada" } -> noop:schema=TestUser
Index ¶
Constants ¶
View Source
const ID = "schema"
Variables ¶
View Source
var Directive = core.Directive{
Name: "schema",
Example: `@schema Plan { Summary string }`,
Handler: handleDirective,
}
Directive parses `@schema NAME { ... }` into a Schema appended to meta["schemas"]. Duplicate names are a compile error.
View Source
var SchemaModifier = core.String("schema", func(b *action.Builder[any, any], name string) *action.Builder[any, any] { return b.Tag("schema:" + name) })
SchemaModifier attaches a schema name to an atom as a tag. The tag is read by the strict-mode validation hook.
Functions ¶
Types ¶
type Field ¶
type Field struct {
Name string
JSONName string
Type string
Kind Kind
ElemType string
Pointer bool
Slice bool
Map bool
Tags map[string]string
}
SchemaField is one parsed field declaration.
Click to show internal directories.
Click to hide internal directories.