validate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package validate checks a feature-flags document against a project catalog: every cross-reference the JSON Schemas cannot express, plus the name and size rules, so callers that never run the schemas (the Flag Console, the library on load) still reject bad documents. The AppConfig validator Lambda runs the same checks at deployment.

Index

Constants

View Source
const (
	// MaxDocumentBytes is the AppConfig hosted configuration and deployment
	// size quota (2,048 KB by default; raising it needs an AWS approval).
	MaxDocumentBytes = 2048 * 1024

	// WarnDocumentPercent is how full the quota may get before CheckSize
	// warns, leaving room to react before saves start failing.
	WarnDocumentPercent = 75
)
View Source
const MaxGroupValues = 200

MaxGroupValues is the most values a group may list. Larger, data-driven segments belong in a resolver or a custom operator.

Variables

This section is empty.

Functions

func CheckSize

func CheckSize(raw []byte) (warning string, err error)

CheckSize checks a document as it will be stored. It returns an error over MaxDocumentBytes, which AppConfig would reject, and a warning over WarnDocumentPercent of it.

func ValidateCatalog

func ValidateCatalog(catalog *document.Catalog) error

ValidateCatalog checks a catalog on its own: names, types, custom operators not shadowing built-ins, and resolvers keyed by and requiring catalog attributes. The error, when not nil, is an *Error.

Types

type Error

type Error struct {
	Problems []Problem
}

Error is returned when the documents are invalid. It lists every problem found, in a stable order.

func (*Error) Error

func (e *Error) Error() string

type Problem

type Problem struct {
	Path    string
	Message string
}

Problem is one finding, located by Path, e.g. `flags.new_withdraw_flow.rules[1] "10% rollout".if[0]`.

func Validate

func Validate(flags *document.Flags, catalog *document.Catalog) (warnings []Problem, err error)

Validate checks flags against catalog, including the catalog itself. Warnings never make the documents invalid; they are for the person editing (e.g. two rules of a flag share a name). The error, when not nil, is an *Error.

Validating the live flags against a new catalog catches removed attributes and operators; ValidateCatalogChange also catches retyped ones.

func ValidateCatalogChange

func ValidateCatalogChange(prev, next *document.Catalog, flags *document.Flags) (warnings []Problem, err error)

ValidateCatalogChange checks a new catalog before it replaces prev. It runs Validate(flags, next), where flags are the flags that will be evaluated against next, and also fails for every attribute those flags use whose type differs between prev and next: a rollout bucket or an exists condition holds no value, so only prev shows the change. A nil prev skips the comparison.

func (Problem) String

func (p Problem) String() string

Jump to

Keyboard shortcuts

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