Documentation
¶
Overview ¶
Package schemix provides a schema-driven validation and transformation engine powered by CUE constraints and Bloblang dynamic expressions.
It combines CUE's declarative type system with Bloblang's scripting capability through three annotation layers:
- CUE native constraints: types, regex, enums, ranges, nested structs, arrays
- @blob() dynamic expressions: Bloblang syntax for validation (bool) and computed fields
- @meta() field behavior control: priority, optional, conditional, skip/omit rules
Quick Start ¶
v := schemix.MustNew(`{
name: string
email: string @blob(this.email.is_email())
age: int @blob(this.age.between(min: 0, max: 150))
pan: =~"^[0-9]{16}$"
luhn: bool @blob(this.pan.luhn_valid())
}`)
r := v.Process(map[string]any{
"name": "Alice", "email": "alice@test.com", "age": int64(30),
"pan": "4111111111111111",
})
if r.Valid {
// use r.Output
}
Built-in Validation Methods ¶
Every Validator automatically includes 37+ built-in validation methods callable in @blob() expressions, covering common format checks:
- String format: is_email, is_url, is_full_url, is_uuid/3/4/5, is_ip/v4/v6, is_cidr, is_mac, is_dns_name, is_cn_mobile, is_json, is_base64, is_hex, is_hex_color, is_rgb_color, is_data_uri, is_latitude, is_longitude, is_isbn10, is_isbn13
- Character type: is_alpha, is_alpha_num, is_alpha_dash, is_numeric, is_number, is_ascii, is_printable_ascii, is_multibyte
- String checks: not_blank, has_whitespace
- Length: len_between(min,max), min_len(n), max_len(n), str_len(min,max)
- Numeric: between(min,max)
- Financial: luhn_valid
- Date functions: is_valid_date, is_past_date, is_future_date
Usage in schema:
email: string @blob(this.email.is_email()) pan: string @blob(this.pan.luhn_valid()) age: int @blob(this.age.between(min: 0, max: 150)) name: string @blob(this.name.len_between(min: 2, max: 50))
Fail Modes ¶
Three strategies control error collection behavior:
- FailAll: collect all errors (default, best for form validation)
- FailFast: stop at first error (best for API gateways)
- FailPriority: priority-group isolation (p1 failure skips p2+)
Error Handling ¶
Result provides multiple ways to inspect errors:
r := v.Process(data)
r.Valid // bool
r.Err() // combined error (nil if valid)
r.FirstError() // *ValidationError
r.ErrorsByPath("pan") // []ValidationError
r.ErrorsByCode(CodeTypeMismatch)// []ValidationError
r.ErrorsByType("cue") // []ValidationError — filter by layer
r.HasCode(CodeBizRuleFailed) // bool — quick check
r.HasErrorsAt("email") // bool — field-level check
Custom Error Messages (i18n) ¶
Provide a custom ErrorFormatter to generate user-facing messages:
v := schemix.MustNew(schema, schemix.WithErrorFormatter(func(code ErrorCode, path, detail string) string {
return myI18n.Translate("zh-CN", string(code), path)
}))
Custom Functions and Methods ¶
Register custom validation logic using the same API as Bloblang:
// Function style (called as: my_func(args...))
v, _ := schemix.New(schema, schemix.WithFunction("check_blacklist",
func(args ...any) (bloblang.Function, error) {
pan := args[0].(string)
return func() (any, error) { return !isBlocked(pan), nil }, nil
},
))
// Method style (called as: this.field.my_method())
v, _ := schemix.New(schema, schemix.WithMethod("is_valid_bin",
func(v any) (any, error) {
return checkBIN(v.(string)), nil
},
))
// V2 style with typed parameters (same as bloblang.RegisterFunctionV2)
v, _ := schemix.New(schema, schemix.WithFunctionV2("calc_fee",
bloblang.NewPluginSpec().
Param(bloblang.NewInt64Param("amount")).
Param(bloblang.NewFloat64Param("rate")),
func(args *bloblang.ParsedParams) (bloblang.Function, error) {
amount, _ := args.GetInt64("amount")
rate, _ := args.GetFloat64("rate")
return func() (any, error) { return float64(amount) * rate, nil }, nil
},
))
Custom functions are isolated per Validator — they do not leak to other instances.
Schema Composition ¶
Use NewFromValue to build validators from pre-compiled CUE values, enabling schema reuse through CUE definitions:
ctx := cuecontext.New()
schema := ctx.CompileString(`{
#PAN: =~"^[0-9]{16}$"
pan: #PAN
amount: int & >0
}`)
v, _ := schemix.NewFromValue(schema)
Schema Introspection ¶
Inspect schema structure at runtime for documentation or UI generation:
fields := v.Fields() // []FieldInfo{Name, Path, Type, Optional, HasBlob, Children}
Performance ¶
Schemix uses a Go-native fast path for simple constraints (type, regex, range, enum), bypassing CUE evaluation entirely. Typical Process latency is 2-3µs for schemas with scalar fields.
Bloblang Pipeline Integration ¶
Register schemas into a Registry for use within Benthos/Redpanda Connect pipelines:
reg := schemix.NewRegistry()
reg.Register("payment", cueSrc)
reg.RegisterAll() // registers both method and function forms
Then use in Bloblang mappings:
let r = this.process_schema(name: "payment", mode: "fast") let r = validate_schema(data: this.payload, name: "payment")
Thread Safety ¶
Validator is safe for concurrent use after construction. Registry uses sync.RWMutex for concurrent Register/Get/Unregister operations.
Package schemix provides a schema-driven validation and transformation engine powered by CUE constraints and Bloblang dynamic expressions.
It combines CUE's declarative type system (@blob() for dynamic rules, @meta() for field behavior control) with recursive multi-level validation, structured error codes, and configurable fail strategies.
Index ¶
- Constants
- func Has(name string) bool
- func Len() int
- func List() []string
- func MustRegister(name string, v *Validator)
- func Register(name string, v *Validator)
- func Unregister(name string) bool
- type ErrorCode
- type ErrorFormatter
- type FailMode
- type FieldInfo
- type FuncMap
- type FuncMapOption
- func Func(name string, fn bloblang.FunctionConstructor) FuncMapOption
- func FuncV2(name string, spec *bloblang.PluginSpec, ctor bloblang.FunctionConstructorV2) FuncMapOption
- func Method(name string, fn bloblang.Method) FuncMapOption
- func MethodV2(name string, spec *bloblang.PluginSpec, ctor bloblang.MethodConstructorV2) FuncMapOption
- type Option
- func WithErrorFormatter(f ErrorFormatter) Option
- func WithFuncMap(m *FuncMap) Option
- func WithFunction(name string, fn bloblang.FunctionConstructor) Option
- func WithFunctionV2(name string, spec *bloblang.PluginSpec, ctor bloblang.FunctionConstructorV2) Option
- func WithMethod(name string, fn bloblang.Method) Option
- func WithMethodV2(name string, spec *bloblang.PluginSpec, ctor bloblang.MethodConstructorV2) Option
- func WithOverrideAll() Option
- func WithOverrideFunc(names ...string) Option
- func WithOverrideMethod(names ...string) Option
- type Processable
- type Registry
- func (r *Registry) Get(name string) (*Validator, bool)
- func (r *Registry) Has(name string) bool
- func (r *Registry) Len() int
- func (r *Registry) List() []string
- func (r *Registry) Register(name, cueSrc string) error
- func (r *Registry) RegisterAll() errordeprecated
- func (r *Registry) RegisterAllTo(env *bloblang.Environment) error
- func (r *Registry) RegisterFunctions() errordeprecated
- func (r *Registry) RegisterFunctionsTo(env *bloblang.Environment) error
- func (r *Registry) RegisterMethods() errordeprecated
- func (r *Registry) RegisterMethodsTo(env *bloblang.Environment) error
- func (r *Registry) Unregister(name string) bool
- type Result
- func (r Result) Err() error
- func (r Result) ErrorMessages() string
- func (r Result) ErrorsByCode(code ErrorCode) []ValidationError
- func (r Result) ErrorsByPath(path string) []ValidationError
- func (r Result) ErrorsByType(typ string) []ValidationError
- func (r Result) FirstError() *ValidationError
- func (r Result) HasCode(code ErrorCode) bool
- func (r Result) HasErrorsAt(path string) bool
- type ValidationError
- type Validator
- func Get(name string) (*Validator, bool)
- func MustGet(name string) *Validator
- func MustNew(cueSrc string, opts ...Option) *Validator
- func New(cueSrc string, opts ...Option) (*Validator, error)
- func NewFromValue(schema cue.Value, opts ...Option) (*Validator, error)
- func NewWithContext(ctx *cue.Context, cueSrc string, opts ...Option) (*Validator, error)
- func (v *Validator) Fields() []FieldInfo
- func (v *Validator) Process(data map[string]any) Result
- func (v *Validator) ProcessValue(data any) Result
- func (v *Validator) ProcessValueWithMode(data any, mode FailMode) Result
- func (v *Validator) ProcessWithMode(data map[string]any, mode FailMode) Result
- func (v *Validator) Validate(data map[string]any) (bool, []ValidationError)
- func (v *Validator) ValidateValue(data any) (bool, []ValidationError)
Constants ¶
const ( ModeAll = "all" ModeFast = "fast" ModePriority = "priority" )
Mode string values for FailMode selection (user-facing).
const ( TypeCUE = "cue" TypeBloblang = "bloblang" TypeMeta = "meta" TypeConfig = "config" )
Validation error type identifiers (user-facing, for filtering ValidationError.Type).
Variables ¶
This section is empty.
Functions ¶
func Has ¶ added in v0.1.4
Has reports whether a Validator with the given name is globally registered.
func List ¶ added in v0.1.4
func List() []string
List returns the names of all globally registered Validators.
func MustRegister ¶ added in v0.1.4
MustRegister stores a pre-compiled Validator globally under name. Panics if name already exists (conflict).
func Register ¶ added in v0.1.4
Register stores a pre-compiled Validator globally under name. If name already exists, it is silently replaced (use MustRegister to reject duplicates).
func Unregister ¶ added in v0.1.4
Unregister removes a globally registered Validator by name. Returns true if it existed and was removed.
Types ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode is a structured error identifier with format E{layer}{category}{seq}.
Layer 1: CUE structural/type validation Layer 2: Bloblang business rules Layer 3: Meta control violations
const ( // Layer 1: CUE structural validation CodeFormatMismatch ErrorCode = "E1F01" // regex format mismatch CodeTypeMismatch ErrorCode = "E1T01" // type conflict CodeEnumInvalid ErrorCode = "E1E01" // enum value not allowed CodeRangeViolation ErrorCode = "E1R01" // numeric range exceeded CodeRequiredMissing ErrorCode = "E1M01" // required field missing CodeArrayElement ErrorCode = "E1A01" // array element validation failed CodeCUEOther ErrorCode = "E1X01" // other CUE error // Layer 2: Bloblang business rules CodeBizRuleFailed ErrorCode = "E2B01" // business rule returned false CodeExprExecError ErrorCode = "E2X01" // expression runtime error CodeBlobTypeMismatch ErrorCode = "E2T01" // @blob type contract violation (WU2) // Layer 3: Meta control CodeCondRequired ErrorCode = "E3C01" // conditional required not met CodeMetaRuntimeError ErrorCode = "E3X01" // meta expression runtime error (required_if/skip_if Query failure) // Layer 0: Configuration / invocation errors CodeConfigError ErrorCode = "E0C01" // invalid configuration (e.g. undefined FailMode) )
type ErrorFormatter ¶ added in v0.1.2
ErrorFormatter customizes the human-readable message in ValidationError. It receives the error code, field path, and the default detail message (which is the raw CUE error or expression text). Return the desired user-facing message string.
Example (i18n):
func myFormatter(code ErrorCode, path, detail string) string {
return i18n.T("zh-CN", string(code), path)
}
type FieldInfo ¶ added in v0.1.2
type FieldInfo struct {
Name string `json:"name"` // field name
Path string `json:"path"` // full dot-path
Type string `json:"type"` // "string", "int", "float", "bool", "struct", "list", "number", "unknown"
Optional bool `json:"optional"` // whether the field is optional
HasBlob bool `json:"has_blob"` // has @blob() annotation
Children []FieldInfo `json:"children,omitempty"` // nested struct fields
}
FieldInfo describes a field in the schema. Returned by Validator.Fields(). This is useful for generating documentation, API specs, or UI forms.
type FuncMap ¶ added in v0.1.2
type FuncMap struct {
// contains filtered or unexported fields
}
FuncMap is a reusable collection of custom functions and methods that can be shared across multiple Validators. Build it once, inject everywhere.
Example:
funcs := schemix.NewFuncMap(
schemix.Func("check_blacklist", myBlacklistFn),
schemix.Func("calc_fee", myFeeFn),
schemix.Method("is_valid_bin", myBinFn),
schemix.MethodV2("in_range", rangeSpec, rangeCtor),
)
v1, _ := schemix.New(schema1, schemix.WithFuncMap(funcs))
v2, _ := schemix.New(schema2, schemix.WithFuncMap(funcs))
func NewFuncMap ¶ added in v0.1.2
func NewFuncMap(opts ...FuncMapOption) *FuncMap
NewFuncMap creates a FuncMap from the given registration options. Returns nil error in FuncMap.Err() if all names are valid.
type FuncMapOption ¶ added in v0.1.2
type FuncMapOption func(*FuncMap)
FuncMapOption defines a registration entry for NewFuncMap.
func Func ¶ added in v0.1.2
func Func(name string, fn bloblang.FunctionConstructor) FuncMapOption
Func registers a custom function (V1 style). In schema: name(args...)
func FuncV2 ¶ added in v0.1.2
func FuncV2(name string, spec *bloblang.PluginSpec, ctor bloblang.FunctionConstructorV2) FuncMapOption
FuncV2 registers a custom function with typed parameters (V2 style). In schema: name(param1: value1, param2: value2)
func Method ¶ added in v0.1.2
func Method(name string, fn bloblang.Method) FuncMapOption
Method registers a custom method (V1 style). In schema: this.field.name()
func MethodV2 ¶ added in v0.1.2
func MethodV2(name string, spec *bloblang.PluginSpec, ctor bloblang.MethodConstructorV2) FuncMapOption
MethodV2 registers a custom method with typed parameters (V2 style). In schema: this.field.name(param1: value1, param2: value2)
type Option ¶ added in v0.1.2
type Option func(*validatorConfig)
Option configures a Validator during construction.
func WithErrorFormatter ¶ added in v0.1.2
func WithErrorFormatter(f ErrorFormatter) Option
WithErrorFormatter sets a custom error message formatter. When set, all ValidationError.Message values will be generated by this function instead of the default English messages.
func WithFuncMap ¶ added in v0.1.2
WithFuncMap injects a pre-built FuncMap into the Validator. If the FuncMap has a validation error (e.g. invalid name), New() will return that error.
func WithFunction ¶ added in v0.1.2
func WithFunction(name string, fn bloblang.FunctionConstructor) Option
WithFunction registers a custom function using Bloblang's FunctionConstructor signature. This is the same signature as bloblang.RegisterFunction — a factory that receives arguments and returns a Function closure.
Example:
v, _ := schemix.New(schema, schemix.WithFunction("is_even", func(args ...any) (bloblang.Function, error) {
n, ok := args[0].(int64)
if !ok {
return nil, fmt.Errorf("is_even requires int64")
}
return func() (any, error) {
return n%2 == 0, nil
}, nil
}))
In schema: check: bool @blob(is_even(this.amount))
func WithFunctionV2 ¶ added in v0.1.2
func WithFunctionV2(name string, spec *bloblang.PluginSpec, ctor bloblang.FunctionConstructorV2) Option
WithFunctionV2 registers a custom function using a PluginSpec for typed parameters. This matches Bloblang's RegisterFunctionV2 signature exactly.
Example:
v, _ := schemix.New(schema, schemix.WithFunctionV2("calculate_fee",
bloblang.NewPluginSpec().
Param(bloblang.NewInt64Param("amount")).
Param(bloblang.NewFloat64Param("rate")),
func(args *bloblang.ParsedParams) (bloblang.Function, error) {
amount, _ := args.GetInt64("amount")
rate, _ := args.GetFloat64("rate")
return func() (any, error) {
return float64(amount) * rate, nil
}, nil
},
))
func WithMethod ¶ added in v0.1.2
WithMethod registers a custom method using the simple style. Methods are called on a target value: this.field.my_method()
Example:
v, _ := schemix.New(schema, schemix.WithMethod("is_valid_luhn", func(v any) (any, error) {
s := v.(string)
return luhnCheck(s), nil
}))
In schema: check: bool @blob(this.pan.is_valid_luhn())
func WithMethodV2 ¶ added in v0.1.2
func WithMethodV2(name string, spec *bloblang.PluginSpec, ctor bloblang.MethodConstructorV2) Option
WithMethodV2 registers a custom method using a PluginSpec for typed parameters. This matches Bloblang's RegisterMethodV2 signature exactly.
Example:
v, _ := schemix.New(schema, schemix.WithMethodV2("has_prefix_any",
bloblang.NewPluginSpec().
Param(bloblang.NewStringParam("prefixes").Description("comma-separated prefixes")),
func(args *bloblang.ParsedParams) (bloblang.Method, error) {
prefixes, _ := args.GetString("prefixes")
parts := strings.Split(prefixes, ",")
return func(v any) (any, error) {
s := v.(string)
for _, p := range parts {
if strings.HasPrefix(s, p) { return true, nil }
}
return false, nil
}, nil
},
))
func WithOverrideAll ¶ added in v0.1.2
func WithOverrideAll() Option
WithOverrideAll disables all built-in conflict checks — any name can be registered regardless of whether it conflicts with a built-in.
func WithOverrideFunc ¶ added in v0.1.2
WithOverrideFunc allows overriding specific built-in functions by name.
func WithOverrideMethod ¶ added in v0.1.2
WithOverride explicitly allows overriding one or more built-in validators in their respective namespace. Use WithOverrideMethod / WithOverrideFunc for namespace-specific overrides, or WithOverrideAll to allow overriding everything.
Example:
// Override specific built-in methods
schemix.WithOverrideMethod("is_email", "luhn_valid")
// Override specific built-in functions
schemix.WithOverrideFunc("is_valid_date")
// Override everything — no conflict checks at all
schemix.WithOverrideAll()
type Processable ¶ added in v0.1.4
Processable is an interface that types can implement to provide custom map conversion logic for use with ProcessValue/ValidateValue. This gives callers full control over how their data is represented.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a thread-safe validator registry for use with Bloblang methods.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates an empty validator registry with a shared CUE context.
func (*Registry) Register ¶
Register compiles and stores a named validator from a CUE schema string. It uses the registry's shared CUE context for efficient memory usage.
func (*Registry) RegisterAll
deprecated
func (*Registry) RegisterAllTo ¶ added in v0.1.4
func (r *Registry) RegisterAllTo(env *bloblang.Environment) error
RegisterAllTo registers both method and function forms into a specific environment. Ownership is enforced.
func (*Registry) RegisterFunctions
deprecated
func (*Registry) RegisterFunctionsTo ¶ added in v0.1.4
func (r *Registry) RegisterFunctionsTo(env *bloblang.Environment) error
RegisterFunctionsTo registers "validate_schema" and "process_schema" as Bloblang functions into a specific environment. Ownership is enforced.
func (*Registry) RegisterMethods
deprecated
func (*Registry) RegisterMethodsTo ¶ added in v0.1.4
func (r *Registry) RegisterMethodsTo(env *bloblang.Environment) error
RegisterMethodsTo registers "validate_schema" and "process_schema" as Bloblang methods into a specific environment. Ownership is enforced: the same env cannot be registered by a different Registry.
func (*Registry) Unregister ¶
Unregister removes a named validator from the registry. Returns true if the validator existed and was removed.
type Result ¶
type Result struct {
Valid bool `json:"valid"`
Errors []ValidationError `json:"errors"`
Output map[string]any `json:"output"`
}
Result holds the output of a Process call.
func ProcessStruct ¶ added in v0.1.4
ProcessStruct validates and processes a struct value with compile-time type safety. The struct is converted to map[string]any via JSON serialization (respects json tags). For hot paths, implement Processable or pass map[string]any directly.
func ProcessStructWithMode ¶ added in v0.1.4
ProcessStructWithMode is like ProcessStruct but accepts a FailMode.
func ProcessWith ¶ added in v0.1.4
ProcessWith validates and processes data using a globally registered Validator. Accepts any supported input type (map, struct, JSON bytes, Processable). Returns a config error if the name is not registered.
func ProcessWithMode ¶ added in v0.1.4
ProcessWithMode validates and processes data using a named global Validator with mode.
func (Result) Err ¶
Err returns nil if validation passed, or a combined error from all validation failures. This is convenient for Go-style error checking:
if err := v.Process(data).Err(); err != nil { ... }
func (Result) ErrorMessages ¶
ErrorMessages returns all error messages joined by newline.
func (Result) ErrorsByCode ¶ added in v0.1.2
func (r Result) ErrorsByCode(code ErrorCode) []ValidationError
ErrorsByCode returns all errors matching the specified error code.
func (Result) ErrorsByPath ¶
func (r Result) ErrorsByPath(path string) []ValidationError
ErrorsByPath returns all errors for a specific field path.
func (Result) ErrorsByType ¶ added in v0.1.2
func (r Result) ErrorsByType(typ string) []ValidationError
ErrorsByType returns all errors of the specified type ("cue", "bloblang", "meta").
func (Result) FirstError ¶
func (r Result) FirstError() *ValidationError
FirstError returns the first validation error, or nil if validation passed.
func (Result) HasCode ¶ added in v0.1.2
HasCode reports whether any error has the specified error code.
func (Result) HasErrorsAt ¶ added in v0.1.2
HasErrorsAt reports whether there are any errors at the specified field path.
type ValidationError ¶
type ValidationError struct {
Code ErrorCode `json:"code"` // structured error code
Path string `json:"path"` // field path (e.g. "merchant.country")
Type string `json:"type"` // "cue", "bloblang", or "meta"
Message string `json:"message"` // human-readable description
}
ValidationError represents a single validation failure.
func ValidateStruct ¶ added in v0.1.4
func ValidateStruct[T any](v *Validator, data T) (bool, []ValidationError)
ValidateStruct validates a struct value with compile-time type safety (no Output).
func ValidateWith ¶ added in v0.1.4
func ValidateWith(name string, data any) (bool, []ValidationError)
ValidateWith validates data using a globally registered Validator (no Output).
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Error implements the error interface for ValidationError.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is a schema-driven validation and transformation engine. It combines CUE static constraints with Bloblang dynamic expressions, supporting recursive multi-level validation, structured error codes, and configurable fail strategies.
Validator is safe for concurrent use after construction.
func Get ¶ added in v0.1.4
Get retrieves a globally registered Validator by name. Returns (nil, false) if name is not registered.
func MustGet ¶ added in v0.1.4
MustGet retrieves a globally registered Validator by name. Panics if name is not registered.
func MustNew ¶
MustNew is like New but panics on error. Useful for package-level initialization with schema literals.
func New ¶
New creates a Validator from a CUE schema string. The schema may use @blob() for dynamic expressions and @meta() for field controls.
func NewFromValue ¶ added in v0.1.2
NewFromValue creates a Validator from a pre-compiled CUE value. This enables schema composition by allowing users to build complex schemas using CUE's native import/definition mechanisms and pass the result directly.
Example:
ctx := cuecontext.New()
defs := ctx.CompileString(`#PAN: =~"^[0-9]{16}$"`)
schema := ctx.CompileString(`{ pan: #PAN, amount: int & >0 }`, cue.Scope(defs))
v, err := schemix.NewFromValue(schema)
func NewWithContext ¶
NewWithContext creates a Validator from a CUE schema string using a shared CUE context. This is more efficient when creating many validators, as they can share compilation state.
func (*Validator) Fields ¶ added in v0.1.2
Fields returns the schema's field descriptors for runtime introspection. This is useful for generating documentation, API specs, or UI forms.
func (*Validator) Process ¶
Process performs validation and value computation using the default FailAll mode.
func (*Validator) ProcessValue ¶ added in v0.1.4
ProcessValue validates and processes any supported input type. Accepts: map[string]any, struct, *struct, []byte (JSON), or Processable. Returns a config error Result if the input type is unsupported or conversion fails.
func (*Validator) ProcessValueWithMode ¶ added in v0.1.4
ProcessValueWithMode validates and processes any supported input type with the given FailMode. Accepts: map[string]any, struct, *struct, []byte (JSON), or Processable.
func (*Validator) ProcessWithMode ¶
ProcessWithMode performs validation and value computation with the specified FailMode.
func (*Validator) Validate ¶
func (v *Validator) Validate(data map[string]any) (bool, []ValidationError)
Validate performs validation only and returns (valid, errors). Unlike Process, it skips deepCopy and Output construction for better performance.
func (*Validator) ValidateValue ¶ added in v0.1.4
func (v *Validator) ValidateValue(data any) (bool, []ValidationError)
ValidateValue performs validation (no Output) on any supported input type. Accepts: map[string]any, struct, *struct, []byte (JSON), or Processable.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
ci/benchgate
Package benchgate provides a fail-closed benchmark regression gate.
|
Package benchgate provides a fail-closed benchmark regression gate. |
|
ci/benchgate/cmd
command
Command benchgate fails CI when benchstat reports significant regressions.
|
Command benchgate fails CI when benchstat reports significant regressions. |