Fake Mirrors
    Preparing search index...

    Class AjvValidator

    Ajv-based validator implementation.

    Provides fast and secure JSON Schema validation with comprehensive error reporting. Uses the Ajv library as the underlying validation engine.

    https://ajv.js.org/ - Ajv documentation

    Implements

    • Registers a JSON Schema with a unique name.

      The schema will be compiled and cached for later validation.

      Parameters

      • name: string

        The unique identifier for the schema.

      • schema: object

        The JSON Schema object.

      Returns this

      This validator for method chaining.

      Error If a schema with the given name is already registered.

    • Validates data against a JSON Schema, acting as a type assertion.

      On failure, it throws a detailed validation error.

      Type Parameters

      • T

        The expected type after validation.

      Parameters

      • name: string

        The name of the schema to validate against.

      • data: unknown

        The data to be validated.

      Returns asserts data is T

      Error If a schema with the given name is not found.

      ValidatorError If validation fails, containing detailed error information.

    • Validates data against a JSON Schema, acting as a type guard.

      On success, it narrows the type of the data to the specified type T.

      Type Parameters

      • T

        The expected type after validation.

      Parameters

      • name: string

        The name of the schema to validate against.

      • data: unknown

        The data to be validated.

      Returns data is T

      true if the data is valid, false otherwise.

      Error If a schema with the given name is not found.

    • Registers the validator as a singleton in the DI container.

      Parameters

      • container: DIContainer

        The DI container to register in.

      Returns void