editor

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 33 Imported by: 0

README

editor

import "github.com/lucasassuncao/yedit/editor"

Package editor provides the bubbletea TUI for editing a YAML file driven by a struct-based schema and a preset source.

Index

Constants

const (
    GroupMutuallyExclusive = spec.GroupMutuallyExclusive
    GroupUnknownKeys       = spec.GroupUnknownKeys
    GroupRules             = spec.GroupRules
)

Variables

Built-in formats, re-exported from spec.

var (
    FormatCIDR            = spec.FormatCIDR
    FormatDate            = spec.FormatDate
    FormatDirectoryPath   = spec.FormatDirectoryPath
    FormatDuration        = spec.FormatDuration
    FormatEmail           = spec.FormatEmail
    FormatFQDN            = spec.FormatFQDN
    FormatGitRef          = spec.FormatGitRef
    FormatHost            = spec.FormatHost
    FormatHostPort        = spec.FormatHostPort
    FormatIP              = spec.FormatIP
    FormatIPv4            = spec.FormatIPv4
    FormatIPv6            = spec.FormatIPv6
    FormatPort            = spec.FormatPort
    FormatPrivateKey      = spec.FormatPrivateKey
    FormatPublicKey       = spec.FormatPublicKey
    FormatSemver          = spec.FormatSemver
    FormatTerraformSource = spec.FormatTerraformSource
    FormatURL             = spec.FormatURL
    FormatUUID            = spec.FormatUUID
)

Explicit rules: operate directly on raw YAML via path strings.

var (
    AllOrNone                     = validate.AllOrNone
    AllOrNoneNested               = validate.AllOrNoneNested
    AtLeastOneOf                  = validate.AtLeastOneOf
    AtLeastOneOfNested            = validate.AtLeastOneOfNested
    CountRange                    = validate.CountRange
    CrossFieldOrdered             = validate.CrossFieldOrdered
    CrossFieldOrderedNested       = validate.CrossFieldOrderedNested
    Deprecated                    = validate.Deprecated
    ExactlyOneOf                  = validate.ExactlyOneOf
    ExactlyOneOfNested            = validate.ExactlyOneOfNested
    ForbiddenIf                   = validate.ForbiddenIf
    MutuallyExclusive             = validate.MutuallyExclusive
    MutuallyExclusiveGroupsNested = validate.MutuallyExclusiveGroupsNested
    MutuallyExclusiveNested       = validate.MutuallyExclusiveNested
    NoDuplicates                  = validate.NoDuplicates
    Required                      = validate.Required
    RequiredIf                    = validate.RequiredIf
    RequiredWith                  = validate.RequiredWith
    UniqueValues                  = validate.UniqueValues
    ValueHasLength                = validate.ValueHasLength
    ValueHasPrefix                = validate.ValueHasPrefix
    ValueHasSuffix                = validate.ValueHasSuffix
    ValueInRange                  = validate.ValueInRange
    ValueMatches                  = validate.ValueMatches
    ValueMatchesFormat            = validate.ValueMatchesFormat
    ValueNotOneOf                 = validate.ValueNotOneOf
    ValueOneOf                    = validate.ValueOneOf
)

FromMetadata rules: driven by Config.Metadata, inert until wired.

var (
    CountFromMetadata      = validate.CountFromMetadata
    DeprecatedFromMetadata = validate.DeprecatedFromMetadata
    FormatFromMetadata     = validate.FormatFromMetadata
    LengthFromMetadata     = validate.LengthFromMetadata
    NotOneOfFromMetadata   = validate.NotOneOfFromMetadata
    OneOfFromMetadata      = validate.OneOfFromMetadata
    PatternFromMetadata    = validate.PatternFromMetadata
    RangeFromMetadata      = validate.RangeFromMetadata
    RequiredFromMetadata   = validate.RequiredFromMetadata
    UniqueFromMetadata     = validate.UniqueFromMetadata
)

RunAll executes all validators against raw/blocks. See validate.RunAll.

var RunAll = validate.RunAll

type AddEntry

AddEntry appends a new entry to a collection-nav block.

type AddEntry struct{}

type AppendPreset

AppendPreset appends preset entries to a collection-nav block. Content is the already-fetched YAML so dispatch stays pure.

type AppendPreset struct{ Name, Content string }

type ApplyDocPreset

type ApplyDocPreset struct{ Name, Content string }

type ApplyPreset

ApplyPreset replaces the block content with the named preset. Content is the already-fetched YAML so dispatch stays pure.

type ApplyPreset struct{ Name, Content string }

type BlockAction

BlockAction is a pure synchronous mutation of blockEditState. Every block-editor mutation passes through blockEditState.dispatch.

type BlockAction interface {
    // contains filtered or unexported methods
}

type CommitBlock

type CommitBlock struct{}

type Config

Config bundles everything the editor needs from the embedding application.

Schema must be a pointer to the Go type describing the YAML document's top level (e.g. &MyConfig{}), introspected through yedit/schema.

Validators run before every save and on the explicit "validate" shortcut. Use editor.MutuallyExclusive and editor.RequiredWith for the common cases.

Metadata populates each field's Hint/Example panel. FieldMeta values are used as-is; yedit never falls back to struct tags. FieldMeta.PreChecked lists sub-fields that start checked in a new block, and FieldMeta.Snippet is the YAML inserted when a sub-field is toggled on, defaulting to "<fieldName>: \n".

type Config struct {
    Path                 string         // YAML file to load; also the default save target when SavePath is empty
    Schema               any            // non-nil struct pointer, typed as any because the editor uses reflection (e.g. &MyConfig{})
    Title                string         // label shown in the TUI header
    BlockPresets         presets.Source // optional; nil disables the preset picker inside block editors
    DocPresets           presets.Source // optional; when set, p on the root list opens a whole-document template picker
    EnableHints          bool           // show the Hint/Example panel; warns when Metadata is unset
    Metadata             MetadataSource // field metadata shown in the hint panel and enforced by the FromMetadata validators
    Validators           []Validator    // rules evaluated before every save and on the validate shortcut
    Hidden               []string       // top-level keys to omit from the UI entirely
    PassthroughKeys      []string       // top-level keys preserved as-is: hidden from all sections and exempt from unknown-key validation
    Theme                theme.Theme    // zero-value resolves to ThemePlain
    NoDeleteConfirm      bool           // skip the "Remove block?" dialog; deletion is still undoable via ctrl+u
    NoValidateOnSave     bool           // allow saving despite validator errors; a warning alert is shown but does not block
    NoSaveConfirm        bool           // skip the "Save changes?" dialog; warning confirms are still shown
    SavePath             string         // write here instead of Path, which is still used for loading
    SchemaRecursionDepth int            // extra levels a self-referential type expands; 0 uses the default (1)
    AnimationDuration    time.Duration  // when > 0, the Hint/Example panel eases open and closed over this duration; 0 keeps the toggle instant and emits no timer messages
    Trace                Trace          // session-observability hooks and the built-in Dump recorder
}

type DeleteBlock

type DeleteBlock struct{ Key string }

type DeleteEntry

DeleteEntry removes the collection entry at SeqIdx.

type DeleteEntry struct{ SeqIdx int }

type DocRedo

type DocRedo struct{}

type DocUndo

type DocUndo struct{}

type DrillIn

type DrillIn struct {
    Key     string
    Defs    []schema.FieldDef
    Kind    schema.Kind
    RelSegs []pathSeg
}

type DrillOut

type DrillOut struct{}

type FieldMeta

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type FieldMeta = spec.FieldMeta

type Format

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type Format = spec.Format

func FormatCustom
func FormatCustom(name string, validate func(string) bool) Format

FormatCustom builds an app-specific format. See spec.FormatCustom.

type MetadataFunc

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type MetadataFunc = spec.MetadataFunc

type MetadataSource

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type MetadataSource = spec.MetadataSource

type ModelAction

ModelAction is handled by model.dispatch and may produce a tea.Cmd only for tea.Quit.

type ModelAction interface {
    // contains filtered or unexported methods
}

type NavigateEntry

NavigateEntry moves the collection cursor to Idx (flush + load).

type NavigateEntry struct{ Idx int }

type OpenBlock

type OpenBlock struct{ Key string }

type Redo

Redo re-applies the most recently undone block snapshot.

type Redo struct{}

type Reload

type Reload struct{}

type Result

Result reports the outcome of an editor session.

type Result struct {
    // Saved is true when at least one save to disk succeeded during the
    // session. It stays true even if the user keeps editing afterwards and
    // quits with unsaved changes.
    Saved bool
    // DumpPath is the path of the session trace file, set when
    // Config.Trace.Dump is true. Empty when Dump is false or the dump file
    // could not be created.
    DumpPath string
}

func Run
func Run(cfg Config) (Result, error)

Run starts the editor TUI and blocks until the user quits. The Config must have Schema and Path set; everything else is optional.

Returns the session Result on a clean quit, or the underlying tea.Program error. A panic inside the editor is recovered and returned as an error instead of crashing the embedding program: Bubble Tea restores the terminal before the panic propagates here, so the host is left with a usable terminal and a normal error to handle.

func RunContext
func RunContext(ctx context.Context, cfg Config) (res Result, err error)

RunContext is Run with a context: cancelling ctx shuts the editor down and makes RunContext return the context's error. Unsaved changes are discarded on cancellation, but Result.Saved still reports any save that completed before it.

type Save

type Save struct{}

type SyncYAML

SyncYAML advances be.node from new YAML content (parse-gated). Checkpoint saves an undo snapshot first: set it for pastes, not for single keystrokes.

type SyncYAML struct {
    Content    string
    Checkpoint bool
}

type ToggleField

ToggleField checks or unchecks the field at NodeIdx in the tree.

type ToggleField struct {
    NodeIdx int
    Checked bool
}

type ToggleHints

type ToggleHints struct{}

type Trace

Trace bundles the editor's session-observability hooks and the built-in Dump-to-JSONL recorder built on them. See docs/SESSION-TRACING.md.

type Trace struct {
    OnAction      func(blockKey string, a BlockAction) // optional; called after every BlockAction, with the key of the block editor it applied to
    OnModelAction func(ModelAction)                    // optional; called after every ModelAction
    OnMsg         func(where string, msg tea.Msg)      // optional; called for every raw tea.Msg before it is routed. where describes the active pane/block/panel (e.g. "block:categories:tree:editing")
    Dump          bool                                 // record every action and keystroke to a JSONL file, reported in Result.DumpPath; composes with the callbacks above
    DumpPath      string                               // explicit path for the Dump file; empty falls back to a timestamped file in the OS temp dir
}

type Undo

Undo restores the previous block snapshot.

type Undo struct{}

type ValidationInput

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type ValidationInput = spec.ValidationInput

func NewValidationInput
func NewValidationInput(raw []byte, blocks []document.Block) ValidationInput

NewValidationInput parses raw once and bundles it with blocks for a validation run. See spec.NewValidationInput.

type Validator

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type Validator = spec.Validator

type ValidatorFunc

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type ValidatorFunc = spec.ValidatorFunc

type Violation

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type Violation = spec.Violation

type WiredValidators

WiredValidators is an opaque handle produced by Wire. See validate.WiredValidators.

type WiredValidators = validate.WiredValidators

func Wire
func Wire(validators []spec.Validator, cfg Config) WiredValidators

Wire prepares a validator slice for use with RunAll, discovering the schema tree from cfg so that FromMetadata validators can fire. It returns a handle where every FromMetadata validator carries the schema and MetadataSource; explicit validators are included as-is. The original slice is never modified.

cfg.Schema must be non-nil for FromMetadata validators to report anything; cfg.Metadata may be nil. Callers that already hold the discovered tree should use validate.WireWithSchema directly, so both sides see the same schema.

Generated by gomarkdoc

Documentation

Overview

Package editor provides the bubbletea TUI for editing a YAML file driven by a struct-based schema and a preset source.

Index

Constants

View Source
const (
	GroupMutuallyExclusive = spec.GroupMutuallyExclusive
	GroupUnknownKeys       = spec.GroupUnknownKeys
	GroupRules             = spec.GroupRules
)

Variables

View Source
var (
	FormatCIDR            = spec.FormatCIDR
	FormatDate            = spec.FormatDate
	FormatDirectoryPath   = spec.FormatDirectoryPath
	FormatDuration        = spec.FormatDuration
	FormatEmail           = spec.FormatEmail
	FormatFQDN            = spec.FormatFQDN
	FormatGitRef          = spec.FormatGitRef
	FormatHost            = spec.FormatHost
	FormatHostPort        = spec.FormatHostPort
	FormatIP              = spec.FormatIP
	FormatIPv4            = spec.FormatIPv4
	FormatIPv6            = spec.FormatIPv6
	FormatPort            = spec.FormatPort
	FormatPrivateKey      = spec.FormatPrivateKey
	FormatPublicKey       = spec.FormatPublicKey
	FormatSemver          = spec.FormatSemver
	FormatTerraformSource = spec.FormatTerraformSource
	FormatURL             = spec.FormatURL
	FormatUUID            = spec.FormatUUID
)

Built-in formats, re-exported from spec.

View Source
var (
	AllOrNone                     = validate.AllOrNone
	AllOrNoneNested               = validate.AllOrNoneNested
	AtLeastOneOf                  = validate.AtLeastOneOf
	AtLeastOneOfNested            = validate.AtLeastOneOfNested
	CountRange                    = validate.CountRange
	CrossFieldOrdered             = validate.CrossFieldOrdered
	CrossFieldOrderedNested       = validate.CrossFieldOrderedNested
	Deprecated                    = validate.Deprecated
	ExactlyOneOf                  = validate.ExactlyOneOf
	ExactlyOneOfNested            = validate.ExactlyOneOfNested
	ForbiddenIf                   = validate.ForbiddenIf
	MutuallyExclusive             = validate.MutuallyExclusive
	MutuallyExclusiveGroupsNested = validate.MutuallyExclusiveGroupsNested
	MutuallyExclusiveNested       = validate.MutuallyExclusiveNested
	NoDuplicates                  = validate.NoDuplicates
	Required                      = validate.Required
	RequiredIf                    = validate.RequiredIf
	RequiredWith                  = validate.RequiredWith
	UniqueValues                  = validate.UniqueValues
	ValueHasLength                = validate.ValueHasLength
	ValueHasPrefix                = validate.ValueHasPrefix
	ValueHasSuffix                = validate.ValueHasSuffix
	ValueInRange                  = validate.ValueInRange
	ValueMatches                  = validate.ValueMatches
	ValueMatchesFormat            = validate.ValueMatchesFormat
	ValueNotOneOf                 = validate.ValueNotOneOf
	ValueOneOf                    = validate.ValueOneOf
)

Explicit rules: operate directly on raw YAML via path strings.

View Source
var (
	CountFromMetadata      = validate.CountFromMetadata
	DeprecatedFromMetadata = validate.DeprecatedFromMetadata
	FormatFromMetadata     = validate.FormatFromMetadata
	LengthFromMetadata     = validate.LengthFromMetadata
	NotOneOfFromMetadata   = validate.NotOneOfFromMetadata
	OneOfFromMetadata      = validate.OneOfFromMetadata
	PatternFromMetadata    = validate.PatternFromMetadata
	RangeFromMetadata      = validate.RangeFromMetadata
	RequiredFromMetadata   = validate.RequiredFromMetadata
	UniqueFromMetadata     = validate.UniqueFromMetadata
)

FromMetadata rules: driven by Config.Metadata, inert until wired.

View Source
var RunAll = validate.RunAll

RunAll executes all validators against raw/blocks. See validate.RunAll.

Functions

This section is empty.

Types

type AddEntry added in v0.22.0

type AddEntry struct{}

AddEntry appends a new entry to a collection-nav block.

type AppendPreset added in v0.40.0

type AppendPreset struct{ Name, Content string }

AppendPreset appends preset entries to a collection-nav block. Content is the already-fetched YAML so dispatch stays pure.

type ApplyDocPreset added in v0.39.0

type ApplyDocPreset struct{ Name, Content string }

type ApplyPreset added in v0.22.0

type ApplyPreset struct{ Name, Content string }

ApplyPreset replaces the block content with the named preset. Content is the already-fetched YAML so dispatch stays pure.

type BlockAction added in v0.22.0

type BlockAction interface {
	// contains filtered or unexported methods
}

BlockAction is a pure synchronous mutation of blockEditState. Every block-editor mutation passes through blockEditState.dispatch.

type CommitBlock added in v0.22.0

type CommitBlock struct{}

type Config

type Config struct {
	Path                 string         // YAML file to load; also the default save target when SavePath is empty
	Schema               any            // non-nil struct pointer, typed as any because the editor uses reflection (e.g. &MyConfig{})
	Title                string         // label shown in the TUI header
	BlockPresets         presets.Source // optional; nil disables the preset picker inside block editors
	DocPresets           presets.Source // optional; when set, p on the root list opens a whole-document template picker
	EnableHints          bool           // show the Hint/Example panel; warns when Metadata is unset
	Metadata             MetadataSource // field metadata shown in the hint panel and enforced by the FromMetadata validators
	Validators           []Validator    // rules evaluated before every save and on the validate shortcut
	Hidden               []string       // top-level keys to omit from the UI entirely
	PassthroughKeys      []string       // top-level keys preserved as-is: hidden from all sections and exempt from unknown-key validation
	Theme                theme.Theme    // zero-value resolves to ThemePlain
	NoDeleteConfirm      bool           // skip the "Remove block?" dialog; deletion is still undoable via ctrl+u
	NoValidateOnSave     bool           // allow saving despite validator errors; a warning alert is shown but does not block
	NoSaveConfirm        bool           // skip the "Save changes?" dialog; warning confirms are still shown
	SavePath             string         // write here instead of Path, which is still used for loading
	SchemaRecursionDepth int            // extra levels a self-referential type expands; 0 uses the default (1)
	AnimationDuration    time.Duration  // when > 0, the Hint/Example panel eases open and closed over this duration; 0 keeps the toggle instant and emits no timer messages
	Trace                Trace          // session-observability hooks and the built-in Dump recorder
}

Config bundles everything the editor needs from the embedding application.

Schema must be a pointer to the Go type describing the YAML document's top level (e.g. &MyConfig{}), introspected through yedit/schema.

Validators run before every save and on the explicit "validate" shortcut. Use editor.MutuallyExclusive and editor.RequiredWith for the common cases.

Metadata populates each field's Hint/Example panel. FieldMeta values are used as-is; yedit never falls back to struct tags. FieldMeta.PreChecked lists sub-fields that start checked in a new block, and FieldMeta.Snippet is the YAML inserted when a sub-field is toggled on, defaulting to "<fieldName>: \n".

type DeleteBlock added in v0.22.0

type DeleteBlock struct{ Key string }

type DeleteEntry added in v0.22.0

type DeleteEntry struct{ SeqIdx int }

DeleteEntry removes the collection entry at SeqIdx.

type DocRedo added in v0.22.0

type DocRedo struct{}

type DocUndo added in v0.22.0

type DocUndo struct{}

type DrillIn added in v0.22.0

type DrillIn struct {
	Key     string
	Defs    []schema.FieldDef
	Kind    schema.Kind
	RelSegs []pathSeg
}

type DrillOut added in v0.22.0

type DrillOut struct{}

type FieldMeta added in v0.16.0

type FieldMeta = spec.FieldMeta

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type Format added in v0.25.0

type Format = spec.Format

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

func FormatCustom added in v0.25.0

func FormatCustom(name string, validate func(string) bool) Format

FormatCustom builds an app-specific format. See spec.FormatCustom.

type MetadataFunc added in v0.22.0

type MetadataFunc = spec.MetadataFunc

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type MetadataSource added in v0.22.0

type MetadataSource = spec.MetadataSource

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type ModelAction added in v0.22.0

type ModelAction interface {
	// contains filtered or unexported methods
}

ModelAction is handled by model.dispatch and may produce a tea.Cmd only for tea.Quit.

type NavigateEntry struct{ Idx int }

NavigateEntry moves the collection cursor to Idx (flush + load).

type OpenBlock added in v0.22.0

type OpenBlock struct{ Key string }

type Redo added in v0.22.0

type Redo struct{}

Redo re-applies the most recently undone block snapshot.

type Reload added in v0.22.0

type Reload struct{}

type Result added in v0.18.0

type Result struct {
	// Saved is true when at least one save to disk succeeded during the
	// session. It stays true even if the user keeps editing afterwards and
	// quits with unsaved changes.
	Saved bool
	// DumpPath is the path of the session trace file, set when
	// Config.Trace.Dump is true. Empty when Dump is false or the dump file
	// could not be created.
	DumpPath string
}

Result reports the outcome of an editor session.

func Run

func Run(cfg Config) (Result, error)

Run starts the editor TUI and blocks until the user quits. The Config must have Schema and Path set; everything else is optional.

Returns the session Result on a clean quit, or the underlying tea.Program error. A panic inside the editor is recovered and returned as an error instead of crashing the embedding program: Bubble Tea restores the terminal before the panic propagates here, so the host is left with a usable terminal and a normal error to handle.

func RunContext added in v0.18.0

func RunContext(ctx context.Context, cfg Config) (res Result, err error)

RunContext is Run with a context: cancelling ctx shuts the editor down and makes RunContext return the context's error. Unsaved changes are discarded on cancellation, but Result.Saved still reports any save that completed before it.

type Save added in v0.22.0

type Save struct{}

type SyncYAML added in v0.22.0

type SyncYAML struct {
	Content    string
	Checkpoint bool
}

SyncYAML advances be.node from new YAML content (parse-gated). Checkpoint saves an undo snapshot first: set it for pastes, not for single keystrokes.

type ToggleField added in v0.22.0

type ToggleField struct {
	NodeIdx int
	Checked bool
}

ToggleField checks or unchecks the field at NodeIdx in the tree.

type ToggleHints added in v0.22.0

type ToggleHints struct{}

type Trace added in v0.48.0

type Trace struct {
	OnAction      func(blockKey string, a BlockAction) // optional; called after every BlockAction, with the key of the block editor it applied to
	OnModelAction func(ModelAction)                    // optional; called after every ModelAction
	OnMsg         func(where string, msg tea.Msg)      // optional; called for every raw tea.Msg before it is routed. where describes the active pane/block/panel (e.g. "block:categories:tree:editing")
	Dump          bool                                 // record every action and keystroke to a JSONL file, reported in Result.DumpPath; composes with the callbacks above
	DumpPath      string                               // explicit path for the Dump file; empty falls back to a timestamped file in the OS temp dir
}

Trace bundles the editor's session-observability hooks and the built-in Dump-to-JSONL recorder built on them. See docs/SESSION-TRACING.md.

type Undo added in v0.22.0

type Undo struct{}

Undo restores the previous block snapshot.

type ValidationInput added in v0.20.0

type ValidationInput = spec.ValidationInput

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

func NewValidationInput added in v0.20.0

func NewValidationInput(raw []byte, blocks []document.Block) ValidationInput

NewValidationInput parses raw once and bundles it with blocks for a validation run. See spec.NewValidationInput.

type Validator

type Validator = spec.Validator

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type ValidatorFunc

type ValidatorFunc = spec.ValidatorFunc

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type Violation added in v0.18.0

type Violation = spec.Violation

These names live in yedit/spec so metadata, docgenerator, validate, and third-party rules can describe a field without importing the TUI. They are aliases, not new types, so consumer code keeps compiling.

type WiredValidators added in v0.38.0

type WiredValidators = validate.WiredValidators

WiredValidators is an opaque handle produced by Wire. See validate.WiredValidators.

func Wire added in v0.38.0

func Wire(validators []spec.Validator, cfg Config) WiredValidators

Wire prepares a validator slice for use with RunAll, discovering the schema tree from cfg so that FromMetadata validators can fire. It returns a handle where every FromMetadata validator carries the schema and MetadataSource; explicit validators are included as-is. The original slice is never modified.

cfg.Schema must be non-nil for FromMetadata validators to report anything; cfg.Metadata may be nil. Callers that already hold the discovered tree should use validate.WireWithSchema directly, so both sides see the same schema.

Jump to

Keyboard shortcuts

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