Function assertStruct

  • Assert a value against a Superstruct struct.

    Throws

    If the value is not valid.

    Type Parameters

    • Type

    • Schema

    Parameters

    • value: unknown

      The value to validate.

    • struct: Struct<Type, Schema>

      The struct to validate against.

    • errorPrefix: string = 'Assertion failed'

      A prefix to add to the error message. Defaults to "Assertion failed".

    • ErrorWrapper: AssertionErrorConstructor = AssertionError

      The error class to throw if the assertion fails. Defaults to AssertionError.

    Returns asserts value is Type