@samatawy/rules
    Preparing search index...

    Class WorkingTypeChecker

    An implementation of TypeChecker that provides top-level type checks for a workspace. It holds the types of all known root types in the workspace. You should not need to use this class directly.

    Implements

    Index

    Constructors

    Properties

    options: Partial<WorkspaceOptions>

    Methods

    • Set or update the options for the type checker. This allows you to configure the behavior of the type checker, such as debugging and validation strictness.

      Parameters

      • options: Partial<WorkspaceOptions>

        an object containing the options to set or update.

      Returns void

    • Indicates whether the type checker should enforce strict syntax validation. When true, the type checker will validate that all rules and expressions conform to expected syntax, potentially throwing errors if syntax is invalid. This can be used to catch issues early in development.

      Returns boolean

    • Indicates whether the type checker should enforce strict input validation. When true, the type checker will validate that all required input data for rules and expressions are defined and conform to expected types, potentially throwing errors if inputs are missing or incorrectly typed.

      Returns boolean

    • Indicates whether the type checker should enforce strict output validation. When true, the type checker will validate that all output data for rules and expressions are defined and conform to expected types, potentially throwing errors if outputs are missing or incorrectly typed.

      Returns boolean

    • Check if the type checker knows the type of the given key. Nested keys can be checked using dot notation (e.g., "user.name").

      Parameters

      • key: string

        the key to check.

      Returns boolean

      true if the type is known, false otherwise.

    • Coerce input data into types acceptable to the known types (as far as possible). Input data can only be a json object but can contain arrays. Can be used to coerce input to a context (e.g. from an HTTP request body). N.B. Unknown keys (i.e. wihout registyered type definitions) will be passed on without coercion. N.B. Recommended to use ONLY after validating input.

      Parameters

      • input: any

        the input data to coerce.

      Returns any

      a deep clone of the input data, with values mutated as necessary to suite declared types.