Documentation
¶
Overview ¶
Package validation collects constraint failures from generated schema validators.
Design ¶
Generated Validate methods report presence, range, format, value and repetition checks to Collector. A supplied support.Target also enables platform and enrollment-context checks for populated fields. Aggregating errors lets callers inspect multiple invalid values in one pass.
This package defines the result types and accumulation behavior. The generator defines schema-specific rules, and schema/support holds availability metadata. Successful structural validation does not prove a payload will install on a physical device.
References ¶
- Decision record 0003: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0003-schema-generator.md
- Decision record 0004: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0004-checkin-and-command-core.md (validated command payloads)
- Decision record 0009: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0009-enrollment-profiles.md (validated profiles)
- 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.