SwiftVerificar-validation — Agent Instructions
Module name: SwiftVerificarValidation
What This Library Does
Core PDF validation engine for the SwiftVerificar ecosystem. Provides rule execution against parsed PDF documents, PD-layer validation types (annotations, fonts, color spaces, structure trees), SA-layer semantic accessibility types, feature extraction, metadata fixing, and serialization. This is the largest package in the suite with 238+ public types across 9 functional layers, 3050+ tests, completed over 19 sprints.
Dependencies
- SwiftVerificarValidationProfiles (required) — provides profile/rule types
- SwiftVerificarParser (optional) — uses
#if canImportwith fallback stubs when not available
Key Public Types
Core
ValidationEngine— protocol defining the validation contractValidationResult— aggregate result of a validation runRuleResult— result of a single rule evaluationValidationError— error types during validationValidationContext— context passed through validation pipeline
Engine
RuleExecutor— executes rules against PDF objectsObjectValidator— validates individual PDF objectsProfileRuleEvaluator— evaluates rules from a validation profileEvaluationContext— context for rule evaluation
Validators
PDFAValidator— base PDF/A validatorPDFA1Validator,PDFA2Validator,PDFA3Validator,PDFA4Validator
PDFUAValidator— base PDF/UA validatorPDFUA1Validator,PDFUA2Validator
Object Model
PDFObject— protocol for all PDF objects in the validation modelPropertyValue— typed property access on PDF objectsValidatedOperator— enum with 70 operators across 14 categories (graphics state, path construction, path painting, clipping, text state, text positioning, text showing, type3 font, color, inline image, XObject, marked content, compatibility, page boundary)
PD Layer (Physical Document)
PDValidationObject— base protocol for PD-layer objectsValidatedDocument— top-level document validation objectValidatedPage— page-level validationValidatedResource— resource dictionary validationValidatedContentStream— content stream validationStructureElementType— enum with 55 cases for PDF structure element typesValidatedStructTreeRoot— structure tree root validationValidatedStructElem— structure element validationValidatedAnnotation— annotation validationAnnotationType— enum with 27 annotation type casesValidatedFont— font validation typesFontSubtype,FontValidation,Type0Font,Type1Font,TrueTypeFont,CIDFontValidatedAcroForm— form field validation- Color space validation:
ColorSpaceFamily,DeviceGray,DeviceRGB,DeviceCMYK,ICCBased,CalGray,CalRGB - External objects:
ICCProfile,JPEG2000,EmbeddedFile,PKCSvalidation - Additional:
OutputIntent,Action,Destination,OptionalContentGroup,Pattern,Shading,XObject,Outline
SA Layer (Semantic Accessibility)
SAObject— protocol for SA-layer objectsSADocument— semantic document representationSAPage— semantic page representationSAStructureRoot— structure tree root in SA layerSANode— generic node in the semantic treeSAStructureElement— structure element in SA layerContentChunkContainer— container for content chunksContentChunkFactory— factory for creating content chunksWCAGValidationContext— context for WCAG validationSADocumentEncoder— serialization of SA documentsSALayerHelpers— utility functions for SA layerSAValidationReport— SA-specific validation report
Features
FeatureExtractor— extracts features from PDF documentsFeatureType— enum of extractable feature categoriesFeatureNode— node in the feature treeFeatureReport— aggregated feature extraction report
Metadata
MetadataFixer— repairs and normalizes PDF metadata- XMP schema types for metadata validation
InfoDictionary— PDF info dictionary access
Common Usage
import SwiftVerificarValidation
// Validate operator types
let op = ValidatedOperator.textShowTj
op.isTextOperator // true
op.category // .textShowing
// Check structure element types
let elemType = StructureElementType.h1
elemType.isHeading // true
elemType.headingLevel // 1
Build Commands
NEVER use swift build or swift test. Always use xcodebuild.
# Build
xcodebuild build -scheme SwiftVerificarValidation -destination 'platform=macOS'
# Test
xcodebuild test -scheme SwiftVerificarValidation -destination 'platform=macOS'
Run these from the /SwiftVerificar-validation/ package directory.
Technical Details
- Swift version: 6.0 (strict concurrency)
- All types are Sendable
- Testing framework: Swift Testing
- Platforms: macOS 14.0+, iOS 17.0+
- Stats: 238+ public types, 3050+ tests, 19 sprints