Documentation
¶
Overview ¶
Package model defines the typed form model consumed by renderers, following the structure documented in go-form-gen.md:97-158. Builders reside in internal/model but return the types defined here. Validation rules expose canonical identifiers (min/max, minLength/maxLength, pattern) with string parameters so renderers can map numeric bounds (including exclusive limits), textual constraints, and regexes onto HTML attributes or runtime validators without sacrificing deterministic JSON snapshots. Schema extensions under the `x-formgen` namespace flow into `FormModel` and `Field` metadata while the curated `UIHints` map surfaces renderer-facing directives such as `placeholder`, `helpText`, `cssClass`, `inputType`, `widget`, `repeaterLabel`, and visibility toggles like `hideLabel`. Renderers can rely on these hints to adjust layout without having to parse raw extension payloads.
Index ¶
Constants ¶
const ( FieldTypeString = internalmodel.FieldTypeString FieldTypeInteger = internalmodel.FieldTypeInteger FieldTypeNumber = internalmodel.FieldTypeNumber FieldTypeBoolean = internalmodel.FieldTypeBoolean FieldTypeArray = internalmodel.FieldTypeArray FieldTypeObject = internalmodel.FieldTypeObject )
const ( RelationshipBelongsTo = internalmodel.RelationshipBelongsTo RelationshipHasOne = internalmodel.RelationshipHasOne RelationshipHasMany = internalmodel.RelationshipHasMany )
const ( ValidationRuleMin = internalmodel.ValidationRuleMin ValidationRuleMax = internalmodel.ValidationRuleMax ValidationRuleMinLength = internalmodel.ValidationRuleMinLength ValidationRuleMaxLength = internalmodel.ValidationRuleMaxLength ValidationRulePattern = internalmodel.ValidationRulePattern )
Validation rule identifiers mirror OpenAPI keyword semantics and are emitted by the form model builder when schemas define matching constraints.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder interface {
Build(form schema.Form) (FormModel, error)
Decorate(form *FormModel) error
}
Builder converts normalized schema forms into form models and applies optional decorators for UI schema overlays.
func NewBuilder ¶
func NewBuilder(options ...BuilderOption) Builder
NewBuilder returns a Builder backed by the internal implementation.
type BuilderOption ¶
type BuilderOption func(*builderOptions)
BuilderOption configures the builder behaviour.
func WithDecorators ¶
func WithDecorators(decorators ...Decorator) BuilderOption
WithDecorators registers decorators that should run when Decorate is called.
func WithLabeler ¶
func WithLabeler(labeler func(string) string) BuilderOption
WithLabeler overrides the default label generation function.
type Decorator ¶
Decorator enriches a form model with additional metadata after the canonical OpenAPI-derived structure has been built.
type DecoratorFunc ¶
DecoratorFunc adapts a function into a Decorator.
func (DecoratorFunc) Decorate ¶
func (fn DecoratorFunc) Decorate(form *FormModel) error
Decorate calls the underlying function.
type Field ¶
type Field = internalmodel.Field
Field mirrors internal model fields for renderer consumption.
type FieldType ¶
type FieldType = internalmodel.FieldType
FieldType re-exports the internal FieldType enumeration.
type FormModel ¶
type FormModel = internalmodel.FormModel
type Relationship ¶
type Relationship = internalmodel.Relationship
Relationship exposes typed relationship metadata alongside the existing dotted keys for backward compatibility. See docs/adr/RELATIONSHIP_STRUCT_ADR.md.
type RelationshipKind ¶
type RelationshipKind = internalmodel.RelationshipKind
RelationshipKind re-exports the relationship enum defined in docs/adr/RELATIONSHIP_STRUCT_ADR.md.
type ValidationRule ¶
type ValidationRule = internalmodel.ValidationRule
ValidationRule represents an OpenAPI-derived constraint. Threshold-based rules encode their limit in Params["value"], pattern rules preserve the original expression in Params["pattern"], and boolean qualifiers such as exclusivity remain string typed to keep JSON snapshots deterministic.