Documentation
¶
Overview ¶
Package validation collects schema validation results for generated types: a Collector the generated Validate methods report into and the Error and Errors types callers inspect.
Why ¶
Apple's schema declares, per key, presence, allowed values, numeric ranges, formats, and repetition limits. Phase 1 of the plan of record generates a Validate method from those constraints (decision record 0003), and the value of that method is in reporting everything wrong with a value in one pass rather than stopping at the first fault, so an operator fixing a profile or a declaration sees the whole list. Generated methods call the Collector for every key with the rule and the key's support entry; given a Target, the Collector also records whether the target OS version and enrollment context accept each key.
The package defines the vocabulary and the accumulator only. The rules are generated, and the support tables live in schema/support.
References ¶
- Decision record 0003: docs/research/decisions/0003-schema-generator.md
- Decision record 0004: docs/research/decisions/0004-checkin-and-command-core.md (validated command payloads)
- Decision record 0009: docs/research/decisions/0009-enrollment-profiles.md (validated profiles)
- Plan of record: docs/research/implementation_plan.md (section 2, the generator; phase 1)
- Apple: https://github.com/apple/device-management/blob/release/docs/schema.md
- Schema: third_party/device-management/docs/schema.yaml (meta-schema)
Index ¶
- Constants
- Variables
- func Index(prefix string, i int) string
- func Join(prefix, key string) string
- type Collector
- func (c *Collector) Enum(path string, present bool, v any, allowed []any)
- func (c *Collector) Err() error
- func (c *Collector) Pattern(path string, present bool, v string, re *regexp.Regexp)
- func (c *Collector) Range(path string, present bool, v float64, minValue, maxValue *float64)
- func (c *Collector) Repetition(path string, present bool, n, minLen, maxLen int)
- func (c *Collector) Required(path string, present bool)
- func (c *Collector) Support(path string, present bool, e *support.Entry)
- func (c *Collector) Target() support.Target
- func (c *Collector) Warnings() Errors
- type Error
- type Errors
Constants ¶
const ( RuleRequired = "required" RuleEnum = "rangelist" RuleRange = "range" RuleFormat = "format" RuleRepetition = "repetition" RuleSupport = "support" )
Rule names used in Error.Rule.
Variables ¶
var ErrValidation = errors.New("schema validation failed")
ErrValidation is the sentinel every Errors value unwraps to.
Functions ¶
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates errors and deprecation warnings.
func (*Collector) Enum ¶
Enum records an error when a present value is not in the allowed list. Values are compared as strings, or numerically when both sides are numbers.
func (*Collector) Repetition ¶
Repetition records an error when a present array's length is outside [min, max]. A max of 0 means unbounded.
func (*Collector) Support ¶
Support records an error when a present key is not supported by the target, and a warning when it is deprecated there.