Skip to main content
Version: 0.3.0

ErrorCollector

age-schema-client v0.3.0


age-schema-client / ErrorCollector

Class: ErrorCollector

Defined in: src/schema/error-collector.ts:19

Collects validation errors during schema validation

Constructors

Constructor

new ErrorCollector(): ErrorCollector;

Returns

ErrorCollector

Methods

addError()

addError(error): void;

Defined in: src/schema/error-collector.ts:28

Add a validation error

Parameters

ParameterTypeDescription
errorSchemaValidationErrorValidation error

Returns

void


addMissingRequiredProperty()

addMissingRequiredProperty(property): void;

Defined in: src/schema/error-collector.ts:37

Add a missing required property error

Parameters

ParameterTypeDescription
propertystringMissing property name

Returns

void


addInvalidPropertyType()

addInvalidPropertyType(
property,
expectedType,
actualType): void;

Defined in: src/schema/error-collector.ts:48

Add an invalid property type error

Parameters

ParameterTypeDescription
propertystringProperty name
expectedTypestringExpected property type
actualTypestringActual property type

Returns

void


addInvalidRelationship()

addInvalidRelationship(edge, message): void;

Defined in: src/schema/error-collector.ts:69

Add an invalid relationship error

Parameters

ParameterTypeDescription
edgestringEdge label
messagestringError message

Returns

void


addCircularDependency()

addCircularDependency(cycle): void;

Defined in: src/schema/error-collector.ts:84

Add a circular dependency error

Parameters

ParameterTypeDescription
cyclestring[]Array of elements in the cycle

Returns

void


addValidationError()

addValidationError(message): void;

Defined in: src/schema/error-collector.ts:98

Add a generic validation error

Parameters

ParameterTypeDescription
messagestringError message

Returns

void


hasErrors()

hasErrors(): boolean;

Defined in: src/schema/error-collector.ts:112

Check if there are any errors

Returns

boolean

Whether there are any errors


getErrors()

getErrors(): SchemaValidationError[];

Defined in: src/schema/error-collector.ts:121

Get all errors

Returns

SchemaValidationError[]

Array of validation errors


getCurrentPath()

getCurrentPath(): string;

Defined in: src/schema/error-collector.ts:130

Get the current path as a string

Returns

string

Current path


pushPath()

pushPath(segment): void;

Defined in: src/schema/error-collector.ts:139

Push a path segment onto the current path

Parameters

ParameterTypeDescription
segmentstringPath segment

Returns

void


popPath()

popPath(): string;

Defined in: src/schema/error-collector.ts:148

Pop a path segment from the current path

Returns

string

Popped path segment


withPath()

withPath<T>(segment, fn): T;

Defined in: src/schema/error-collector.ts:158

Execute a function with a path segment added to the current path

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
segmentstringPath segment
fn() => TFunction to execute

Returns

T


throwIfErrors()

throwIfErrors(): void;

Defined in: src/schema/error-collector.ts:172

Throw a ValidationErrorCollection if there are any errors

Returns

void

Throws

ValidationErrorCollection if there are any errors