Documentation
¶
Index ¶
- func CoerceContractFieldValidationRows(contract *Contract, rows []map[string]any) []map[string]any
- func CollectColumnNames(rows []map[string]any) []string
- func ContractData(payload *Payload) ([]string, []map[string]any, error)
- func ContractHasFieldValidations(contract *Contract) bool
- func ContractValidationRuleStrings() []string
- func DetectJSONRootShape(body []byte) model.ContractRootShape
- func FieldPathExists(rows []map[string]any, fieldPath string) bool
- func InferContractField(rows []map[string]any, fieldName string) (model.ContractFieldType, bool)
- func InferFieldType(val any) model.ContractFieldType
- func MergeContractFieldType(current model.ContractFieldType, next model.ContractFieldType) model.ContractFieldType
- func MissingRequiredField(columnNames []string, rows []map[string]any, contract *Contract) (string, bool)
- func ParseCSVBodyToRows(body []byte) ([]map[string]any, []string, error)
- func ParseJSONBodyToRows(body []byte) ([]map[string]any, []string, error)
- func ParseJSONBodyToRowsPreserveNumbers(body []byte) ([]map[string]any, []string, error)
- func ProvenanceStrings() []string
- func ResolveFieldPathValues(root map[string]any, fieldPath string) ([]any, bool, bool, error)
- func ValidateContractFieldDeclarations(contract *Contract) error
- func VerificationStatusStrings() []string
- type Contract
- type ContractField
- type ContractFieldValidationError
- type ContractFieldValidations
- type ContractValidationRule
- func (i ContractValidationRule) IsAContractValidationRule() bool
- func (i ContractValidationRule) MarshalJSON() ([]byte, error)
- func (i ContractValidationRule) MarshalText() ([]byte, error)
- func (i ContractValidationRule) String() string
- func (i *ContractValidationRule) UnmarshalJSON(data []byte) error
- func (i *ContractValidationRule) UnmarshalText(text []byte) error
- type Output
- type Payload
- type Provenance
- type VerificationStatus
- func (i VerificationStatus) IsAVerificationStatus() bool
- func (i VerificationStatus) MarshalJSON() ([]byte, error)
- func (i VerificationStatus) MarshalText() ([]byte, error)
- func (i VerificationStatus) String() string
- func (i *VerificationStatus) UnmarshalJSON(data []byte) error
- func (i *VerificationStatus) UnmarshalText(text []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoerceContractFieldValidationRows ¶
func CoerceContractFieldValidationRows( contract *Contract, rows []map[string]any, ) []map[string]any
CoerceContractFieldValidationRows converts serialized row values into declared scalar types for validation-only checks at string-backed boundaries such as CSV.
func CollectColumnNames ¶
func ContractHasFieldValidations ¶
ContractHasFieldValidations reports whether any field declares a validation rule that must be enforced at static or runtime contract boundaries.
func ContractValidationRuleStrings ¶
func ContractValidationRuleStrings() []string
ContractValidationRuleStrings returns a slice of all String values of the enum
func DetectJSONRootShape ¶
func DetectJSONRootShape(body []byte) model.ContractRootShape
DetectJSONRootShape reports whether a JSON payload is a top-level object or array. Unknown is returned for empty, malformed, scalar, or null payloads.
func FieldPathExists ¶
FieldPathExists returns true when at least one row can resolve the full field path without missing any branch in that row.
func InferContractField ¶
func InferFieldType ¶
func InferFieldType(val any) model.ContractFieldType
InferFieldType maps a Go runtime value to the nearest ContractFieldType.
func MergeContractFieldType ¶
func MergeContractFieldType( current model.ContractFieldType, next model.ContractFieldType, ) model.ContractFieldType
func MissingRequiredField ¶
func ParseCSVBodyToRows ¶
ParseCSVBodyToRows decodes a CSV body into rows. The first row is treated as a header. Values are always strings.
func ParseJSONBodyToRows ¶
ParseJSONBodyToRows decodes a JSON body (array or object) into rows. Arrays produce one row per element; a top-level object produces a single row. Scalars, null, and malformed JSON are rejected as unsupported.
func ParseJSONBodyToRowsPreserveNumbers ¶
ParseJSONBodyToRowsPreserveNumbers decodes JSON rows while retaining json.Number values so callers can distinguish integer and decimal literals.
func ProvenanceStrings ¶
func ProvenanceStrings() []string
ProvenanceStrings returns a slice of all String values of the enum
func ResolveFieldPathValues ¶
ResolveFieldPathValues walks a field path through nested maps/arrays and returns all matched terminal values. It also reports whether the path existed and whether any branch had missing segments.
func ValidateContractFieldDeclarations ¶
ValidateContractFieldDeclarations checks that field validations are syntactically valid and compatible with their owning field and contract representation.
func VerificationStatusStrings ¶
func VerificationStatusStrings() []string
VerificationStatusStrings returns a slice of all String values of the enum
Types ¶
type Contract ¶
type Contract struct {
Name string `json:"name" yaml:"name" validate:"required"`
Representation model.ContractRepresentation `json:"representation,omitempty" yaml:"representation,omitempty" validate:"omitempty,contractrepresentation"`
RootShape model.ContractRootShape `json:"root_shape,omitempty" yaml:"root_shape,omitempty" validate:"omitempty,contractrootshape"`
Fields []ContractField `json:"fields,omitempty" yaml:"fields,omitempty" validate:"omitempty,dive"`
}
func CloneContract ¶
type ContractField ¶
type ContractField struct {
Name string `json:"name" yaml:"name" validate:"required"`
Type model.ContractFieldType `json:"type" yaml:"type" validate:"required,contractfieldtype"`
Required bool `json:"required" yaml:"required"`
Nullable bool `json:"nullable,omitempty" yaml:"nullable,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Validations *ContractFieldValidations `json:"validations,omitempty" yaml:"validations,omitempty"`
}
func DeriveContractFields ¶
func DeriveContractFields(payload *Payload) []ContractField
type ContractFieldValidationError ¶
type ContractFieldValidationError struct {
ContractName string
FieldName string
Rule ContractValidationRule
ViolationCount int
}
ContractFieldValidationError summarizes a failed field validation without carrying payload values into logs, API responses, or persisted diagnostics.
func ValidateContractFieldValues ¶
func ValidateContractFieldValues( contract *Contract, rows []map[string]any, ) *ContractFieldValidationError
ValidateContractFieldValues checks runtime rows against declared field validations and returns the first safe failure summary.
func (*ContractFieldValidationError) Error ¶
func (f *ContractFieldValidationError) Error() string
func (ContractFieldValidationError) Summary ¶
func (f ContractFieldValidationError) Summary() string
Summary renders a safe operator-facing validation failure summary.
type ContractFieldValidations ¶
type ContractFieldValidations struct {
Format string `json:"format,omitempty" yaml:"format,omitempty"`
Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
Min any `json:"min,omitempty" yaml:"min,omitempty"`
Max any `json:"max,omitempty" yaml:"max,omitempty"`
MinLength *int `json:"min_length,omitempty" yaml:"min_length,omitempty"`
MaxLength *int `json:"max_length,omitempty" yaml:"max_length,omitempty"`
Unique *bool `json:"unique,omitempty" yaml:"unique,omitempty"`
}
func CloneContractFieldValidations ¶
func CloneContractFieldValidations( validations *ContractFieldValidations, ) *ContractFieldValidations
func (*ContractFieldValidations) UnmarshalJSON ¶
func (v *ContractFieldValidations) UnmarshalJSON(data []byte) error
UnmarshalJSON preserves numeric validation literals exactly while leaving non-contract dynamic pipeline values on the default JSON decoding path.
func (*ContractFieldValidations) UnmarshalYAML ¶
func (v *ContractFieldValidations) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML rejects malformed validation rule declarations before zero values can make null rules indistinguishable from omitted rules.
type ContractValidationRule ¶
type ContractValidationRule int
ContractValidationRule identifies a supported field-level contract validation.
const ( ContractValidationRuleUnknown ContractValidationRule = iota // unknown ContractValidationRuleFormat // format ContractValidationRuleEnum // enum ContractValidationRuleMin // min ContractValidationRuleMax // max ContractValidationRuleMinLength // min_length ContractValidationRuleMaxLength // max_length ContractValidationRuleUnique // unique )
func ContractValidationRuleString ¶
func ContractValidationRuleString(s string) (ContractValidationRule, error)
ContractValidationRuleString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ContractValidationRuleValues ¶
func ContractValidationRuleValues() []ContractValidationRule
ContractValidationRuleValues returns all values of the enum
func (ContractValidationRule) IsAContractValidationRule ¶
func (i ContractValidationRule) IsAContractValidationRule() bool
IsAContractValidationRule returns "true" if the value is listed in the enum definition. "false" otherwise
func (ContractValidationRule) MarshalJSON ¶
func (i ContractValidationRule) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for ContractValidationRule
func (ContractValidationRule) MarshalText ¶
func (i ContractValidationRule) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for ContractValidationRule
func (ContractValidationRule) String ¶
func (i ContractValidationRule) String() string
func (*ContractValidationRule) UnmarshalJSON ¶
func (i *ContractValidationRule) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for ContractValidationRule
func (*ContractValidationRule) UnmarshalText ¶
func (i *ContractValidationRule) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for ContractValidationRule
type Output ¶
type Output struct {
OutputKind model.TransformOutputKind `json:"output_kind"`
RowCount int `json:"row_count"`
IsHeadlessCSV bool `json:"is_headless_csv,omitempty"`
ColumnNames []string `json:"column_names,omitempty"`
Rows []map[string]any `json:"rows,omitempty"`
Document json.RawMessage `json:"document,omitempty"`
CSV string `json:"csv,omitempty"`
}
type Payload ¶
type Payload struct {
Representation model.ContractRepresentation `json:"representation"`
RootShape model.ContractRootShape `json:"root_shape,omitempty"`
Contract *Contract `json:"contract,omitempty"`
VerificationStatus VerificationStatus `json:"verification_status,omitempty"`
Provenance Provenance `json:"provenance,omitempty"`
ColumnNames []string `json:"column_names,omitempty"`
RowCount int `json:"row_count,omitempty"`
Rows []map[string]any `json:"rows,omitempty"`
Document json.RawMessage `json:"document,omitempty"`
CSV string `json:"csv,omitempty"`
File *filepayload.FilePayloadMetadata `json:"file,omitempty"`
FileBytes []byte `json:"-" yaml:"-"`
Form *formpayload.FormData `json:"form,omitempty"`
}
type Provenance ¶
type Provenance int
const ( ProvenanceUnknown Provenance = iota // unknown ProvenanceExecutionResult // execution_result ProvenanceTransformOutput // transform_output ProvenanceRunInput // run_input )
func ProvenanceString ¶
func ProvenanceString(s string) (Provenance, error)
ProvenanceString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ProvenanceValues ¶
func ProvenanceValues() []Provenance
ProvenanceValues returns all values of the enum
func (Provenance) IsAProvenance ¶
func (i Provenance) IsAProvenance() bool
IsAProvenance returns "true" if the value is listed in the enum definition. "false" otherwise
func (Provenance) MarshalJSON ¶
func (i Provenance) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for Provenance
func (Provenance) MarshalText ¶
func (i Provenance) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for Provenance
func (Provenance) String ¶
func (i Provenance) String() string
func (*Provenance) UnmarshalJSON ¶
func (i *Provenance) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for Provenance
func (*Provenance) UnmarshalText ¶
func (i *Provenance) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for Provenance
type VerificationStatus ¶
type VerificationStatus int
const ( VerificationStatusUnknown VerificationStatus = iota // unknown VerificationStatusVerified // verified VerificationStatusTransitivelyVerified // transitively_verified VerificationStatusStaleIntrospection // stale_introspection VerificationStatusIncompatible // incompatible )
func VerificationStatusString ¶
func VerificationStatusString(s string) (VerificationStatus, error)
VerificationStatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func VerificationStatusValues ¶
func VerificationStatusValues() []VerificationStatus
VerificationStatusValues returns all values of the enum
func (VerificationStatus) IsAVerificationStatus ¶
func (i VerificationStatus) IsAVerificationStatus() bool
IsAVerificationStatus returns "true" if the value is listed in the enum definition. "false" otherwise
func (VerificationStatus) MarshalJSON ¶
func (i VerificationStatus) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for VerificationStatus
func (VerificationStatus) MarshalText ¶
func (i VerificationStatus) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for VerificationStatus
func (VerificationStatus) String ¶
func (i VerificationStatus) String() string
func (*VerificationStatus) UnmarshalJSON ¶
func (i *VerificationStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for VerificationStatus
func (*VerificationStatus) UnmarshalText ¶
func (i *VerificationStatus) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for VerificationStatus