/** * Canonical Validation Module * * Runtime validation functions and type guards for all canonical types * in the Vorion Platform. * * Use these functions to validate data at runtime boundaries (API inputs, * external data sources, configuration loading, etc.) * * @packageDocumentation */ import { TrustBand, ObservationTier, DataSensitivity, Reversibility, ActionType, ProofEventType, ComponentType, ComponentStatus, ApprovalType } from '../v2/enums.js'; import { TrustFactorScores, BandThresholds, RiskProfile } from '../v2/trust-profile.js'; import { TrustDeltaReason } from '../v2/trust-delta.js'; import { DenialReason } from '../v2/decision.js'; /** * Valid range for trust scores (0-1000 canonical scale) */ export declare const TRUST_SCORE_RANGE: { readonly min: 0; readonly max: 1000; }; /** * Valid range for trust factor scores (0.0-1.0 normalized scale) * Note: Factor scores use 0.0-1.0, composite score uses 0-1000 */ export declare const FACTOR_SCORE_RANGE: { readonly min: 0; readonly max: 1; }; /** * Custom error class for validation failures */ export declare class ValidationError extends Error { readonly field: string; readonly value: unknown; readonly expected: string; constructor(message: string, field: string, value: unknown, expected: string); } /** * Check if a value is a valid TrustBand */ export declare function isTrustBand(value: unknown): value is TrustBand; /** * Check if a value is a valid TrustBand name (string form) */ export declare function isTrustBandName(value: unknown): value is keyof typeof TrustBand; /** * Assert that a value is a valid TrustBand * @throws ValidationError if invalid */ export declare function assertValidTrustBand(value: unknown, field?: string): asserts value is TrustBand; /** * Parse a trust band from string or number */ export declare function parseTrustBand(value: unknown): TrustBand | null; /** * Check if a value is a valid trust score (0-100) */ export declare function isTrustScore(value: unknown): value is number; /** * Assert that a value is a valid trust score * @throws ValidationError if invalid */ export declare function assertValidTrustScore(value: unknown, field?: string): asserts value is number; /** * Clamp a trust score to valid range */ export declare function clampTrustScore(value: number): number; /** * Round a trust score to specified decimal places */ export declare function roundTrustScore(value: number, decimals?: number): number; /** * Check if a value is a valid ObservationTier */ export declare function isObservationTier(value: unknown): value is ObservationTier; /** * Assert that a value is a valid ObservationTier * @throws ValidationError if invalid */ export declare function assertValidObservationTier(value: unknown, field?: string): asserts value is ObservationTier; /** * Get the trust ceiling for an observation tier */ export declare function getObservationCeiling(tier: ObservationTier): number; /** * Apply observation ceiling to a trust score */ export declare function applyObservationCeiling(score: number, tier: ObservationTier): number; /** * Check if a value is a valid DataSensitivity */ export declare function isDataSensitivity(value: unknown): value is DataSensitivity; /** * Assert that a value is a valid DataSensitivity * @throws ValidationError if invalid */ export declare function assertValidDataSensitivity(value: unknown, field?: string): asserts value is DataSensitivity; /** * Get numeric severity level for data sensitivity (0-3) */ export declare function getDataSensitivityLevel(sensitivity: DataSensitivity): number; /** * Check if a value is a valid Reversibility */ export declare function isReversibility(value: unknown): value is Reversibility; /** * Assert that a value is a valid Reversibility * @throws ValidationError if invalid */ export declare function assertValidReversibility(value: unknown, field?: string): asserts value is Reversibility; /** * Check if a value is a valid ActionType */ export declare function isActionType(value: unknown): value is ActionType; /** * Assert that a value is a valid ActionType * @throws ValidationError if invalid */ export declare function assertValidActionType(value: unknown, field?: string): asserts value is ActionType; /** * Check if a value is a valid ProofEventType */ export declare function isProofEventType(value: unknown): value is ProofEventType; /** * Assert that a value is a valid ProofEventType * @throws ValidationError if invalid */ export declare function assertValidProofEventType(value: unknown, field?: string): asserts value is ProofEventType; /** * Check if a value is a valid ComponentType */ export declare function isComponentType(value: unknown): value is ComponentType; /** * Assert that a value is a valid ComponentType * @throws ValidationError if invalid */ export declare function assertValidComponentType(value: unknown, field?: string): asserts value is ComponentType; /** * Check if a value is a valid ComponentStatus */ export declare function isComponentStatus(value: unknown): value is ComponentStatus; /** * Assert that a value is a valid ComponentStatus * @throws ValidationError if invalid */ export declare function assertValidComponentStatus(value: unknown, field?: string): asserts value is ComponentStatus; /** * Check if a value is a valid ApprovalType */ export declare function isApprovalType(value: unknown): value is ApprovalType; /** * Assert that a value is a valid ApprovalType * @throws ValidationError if invalid */ export declare function assertValidApprovalType(value: unknown, field?: string): asserts value is ApprovalType; /** * Check if a value is a valid TrustDeltaReason */ export declare function isTrustDeltaReason(value: unknown): value is TrustDeltaReason; /** * Assert that a value is a valid TrustDeltaReason * @throws ValidationError if invalid */ export declare function assertValidTrustDeltaReason(value: unknown, field?: string): asserts value is TrustDeltaReason; /** * Check if a value is a valid DenialReason */ export declare function isDenialReason(value: unknown): value is DenialReason; /** * Assert that a value is a valid DenialReason * @throws ValidationError if invalid */ export declare function assertValidDenialReason(value: unknown, field?: string): asserts value is DenialReason; /** * Check if a value is a valid RiskProfile */ export declare function isRiskProfile(value: unknown): value is RiskProfile; /** * Assert that a value is a valid RiskProfile * @throws ValidationError if invalid */ export declare function assertValidRiskProfile(value: unknown, field?: string): asserts value is RiskProfile; /** * Check if a value has valid TrustFactorScores structure */ export declare function isTrustFactorScores(value: unknown): value is TrustFactorScores; /** * Assert that a value has valid TrustFactorScores * @throws ValidationError if invalid */ export declare function assertValidTrustFactorScores(value: unknown, field?: string): asserts value is TrustFactorScores; /** * Check if a value has valid BandThresholds structure */ export declare function isBandThresholds(value: unknown): value is BandThresholds; /** * Assert that a value has valid BandThresholds * @throws ValidationError if invalid */ export declare function assertValidBandThresholds(value: unknown, field?: string): asserts value is BandThresholds; /** * Calculate the trust band for a given score using default thresholds */ export declare function calculateTrustBand(score: number, thresholds?: BandThresholds): TrustBand; /** * Calculate composite trust score from factor scores * Simple average scaled to 0-1000 */ export declare function calculateCompositeScore(factorScores: TrustFactorScores): number; /** * Validate all fields of an object against a schema */ export declare function validateObject>(obj: unknown, validators: Record void>): obj is T;