contentvalidator

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package contentvalidator provides content structure validation for template versions.

Index

Constants

View Source
const (
	// Parse errors
	ErrCodeInvalidJSON  = "INVALID_JSON"
	ErrCodeEmptyContent = "EMPTY_CONTENT"

	// Structure errors
	ErrCodeInvalidVersion    = "INVALID_VERSION_FORMAT"
	ErrCodeMissingMetaTitle  = "MISSING_META_TITLE"
	ErrCodeInvalidLanguage   = "INVALID_LANGUAGE"
	ErrCodeInvalidPageFormat = "INVALID_PAGE_FORMAT"
	ErrCodeInvalidPageSize   = "INVALID_PAGE_SIZE"
	ErrCodeInvalidMargins    = "INVALID_MARGINS"

	ErrCodeInaccessibleInjectable = "INACCESSIBLE_INJECTABLE"

	// Variable errors
	ErrCodeUnknownVariable      = "UNKNOWN_VARIABLE"
	ErrCodeInaccessibleVariable = "INACCESSIBLE_VARIABLE"
	ErrCodeOrphanedVariable     = "ORPHANED_VARIABLE"
	ErrCodeInvalidInjectorType  = "INVALID_INJECTOR_TYPE"

	// Conditional errors
	ErrCodeInvalidConditionVar   = "UNKNOWN_VARIABLE_IN_CONDITION"
	ErrCodeInvalidOperator       = "INVALID_OPERATOR"
	ErrCodeInvalidLogicOperator  = "INVALID_LOGIC_OPERATOR"
	ErrCodeExpressionSyntax      = "EXPRESSION_SYNTAX_ERROR"
	ErrCodeMaxNestingExceeded    = "MAX_NESTING_EXCEEDED"
	ErrCodeInvalidRuleValueMode  = "INVALID_RULE_VALUE_MODE"
	ErrCodeInvalidConditionAttrs = "INVALID_CONDITION_ATTRS"
	ErrCodeEmptyConditionGroup   = "EMPTY_CONDITION_GROUP"
	ErrCodeMissingConditionValue = "MISSING_CONDITION_VALUE"

	// Context errors
	ErrCodeValidationCancelled = "VALIDATION_CANCELLED"
)

Error codes for content validation. These codes are returned in ValidationError.Code to identify specific validation failures.

View Source
const (
	WarnCodeDeprecatedVersion = "DEPRECATED_VERSION"
	WarnCodeExpressionWarning = "EXPRESSION_WARNING"
	WarnCodeUnusedVariable    = "UNUSED_VARIABLE"
)

Warning codes for content validation. These codes are returned in ValidationWarning.Code for non-blocking issues.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Service)

Option configures the validator service.

func WithMaxNestingDepth

func WithMaxNestingDepth(depth int) Option

WithMaxNestingDepth sets the maximum conditional nesting depth. Default is 3.

func WithStrictMode

func WithStrictMode() Option

WithStrictMode enables strict validation mode. In strict mode, warnings are treated as errors.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements the ContentValidator interface.

func New

func New(injectableUC injectableuc.InjectableUseCase, opts ...Option) *Service

New creates a new content validator service.

func (*Service) ValidateForDraft

func (s *Service) ValidateForDraft(ctx context.Context, content []byte) *port.ContentValidationResult

ValidateForDraft performs minimal validation for draft mode.

func (*Service) ValidateForPublish

func (s *Service) ValidateForPublish(
	ctx context.Context,
	workspaceID, versionID string,
	content []byte,
) *port.ContentValidationResult

ValidateForPublish performs complete validation for publish mode.

Jump to

Keyboard shortcuts

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