Skip to content

Documentation / @agentick/shared / ValidationError

Class: ValidationError

Defined in: errors.ts:308

Error thrown when input validation fails.

Example

typescript
throw new ValidationError('messages', 'Messages are required');
throw new ValidationError('handler', 'Handler function required', { expected: 'function' });
throw new ValidationError('input.model', 'Model identifier must be provided');

Extends

Constructors

Constructor

new ValidationError(field, message, options?, cause?): ValidationError

Defined in: errors.ts:318

Parameters

field

string

message

string

options?
code?

"VALIDATION_REQUIRED" | "VALIDATION_TYPE" | "VALIDATION_FORMAT" | "VALIDATION_CONSTRAINT"

expected?

string

received?

string

cause?

Error

Returns

ValidationError

Overrides

AgentickError.constructor

Properties

cause?

readonly optional cause: Error

Defined in: errors.ts:108

Original error that caused this error

Inherited from

AgentickError.cause


code

readonly code: AgentickErrorCode

Defined in: errors.ts:102

Unique error code for programmatic handling

Inherited from

AgentickError.code


details

readonly details: Record<string, unknown>

Defined in: errors.ts:105

Additional error details

Inherited from

AgentickError.details


expected?

readonly optional expected: string

Defined in: errors.ts:313

Expected type or format (optional)


field

readonly field: string

Defined in: errors.ts:310

Field or parameter that failed validation


received?

readonly optional received: string

Defined in: errors.ts:316

Actual value received (optional)

Methods

fromJSON()

static fromJSON(json): AgentickError

Defined in: errors.ts:169

Create error from serialized format

Parameters

json

SerializedAgentickError

Returns

AgentickError

Inherited from

AgentickError.fromJSON


required()

static required(field, message?): ValidationError

Defined in: errors.ts:353

Create a "required" validation error

Parameters

field

string

message?

string

Returns

ValidationError


toJSON()

toJSON(): SerializedAgentickError

Defined in: errors.ts:137

Serialize error for transport (JSON-safe)

Returns

SerializedAgentickError

Inherited from

AgentickError.toJSON


type()

static type(field, expected, received?): ValidationError

Defined in: errors.ts:362

Create a "type mismatch" validation error

Parameters

field

string

expected

string

received?

string

Returns

ValidationError

Released under the ISC License.