ErrorCollector
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
| Parameter | Type | Description |
|---|---|---|
error | SchemaValidationError | Validation error |
Returns
void
addMissingRequiredProperty()
addMissingRequiredProperty(property): void;
Defined in: src/schema/error-collector.ts:37
Add a missing required property error
Parameters
| Parameter | Type | Description |
|---|---|---|
property | string | Missing 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
| Parameter | Type | Description |
|---|---|---|
property | string | Property name |
expectedType | string | Expected property type |
actualType | string | Actual property type |
Returns
void
addInvalidRelationship()
addInvalidRelationship(edge, message): void;
Defined in: src/schema/error-collector.ts:69
Add an invalid relationship error
Parameters
| Parameter | Type | Description |
|---|---|---|
edge | string | Edge label |
message | string | Error message |
Returns
void
addCircularDependency()
addCircularDependency(cycle): void;
Defined in: src/schema/error-collector.ts:84
Add a circular dependency error
Parameters
| Parameter | Type | Description |
|---|---|---|
cycle | string[] | 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
| Parameter | Type | Description |
|---|---|---|
message | string | Error 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
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
| Parameter | Type | Description |
|---|---|---|
segment | string | Path 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
| Parameter | Type | Description |
|---|---|---|
segment | string | Path segment |
fn | () => T | Function 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