-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
28 lines (28 loc) · 1.46 KB
/
Copy pathdoc.go
File metadata and controls
28 lines (28 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Package dyfields defines forms at runtime: build a schema by adding and
// removing fields, write it out as JSON, read it back, and validate values
// against it. It has no dependencies outside the standard library.
//
// A schema is plain data, so it can be written by hand, stored, and shipped to
// a front end as render instructions. Builder is the convenient way to produce
// one from code:
//
// b := dyfields.NewBuilder()
// b.AddField(dyfields.String("cluster").Label("Cluster").Required())
// b.AddField(dyfields.Secret("password").Required().MinLength(8))
// c, err := b.Compile()
//
// Compile checks the definition itself — names unique, references resolvable
// and acyclic, containers well-formed — and returns a SchemaErrors listing
// every problem at once. Load does the same starting from JSON, and
// ValidateSchema answers only whether a JSON schema is usable.
//
// Values travel in a ValueDocument, which keeps secrets in a separate flat
// container so that Values can be logged or exported wholesale without leaking
// one. Validate checks a complete document; Apply merges a Patch into an
// existing one and is the only place readonly is enforced, because rejecting a
// change needs a baseline to compare against.
//
// Entries of an object_list carry a "$id" that gives them a stable identity
// across edits. Secret keys are built from that id, never from an index, so
// deleting an entry cannot shift someone else's secret onto the wrong row.
package dyfields