Helpful
    Preparing search index...

    Represents an object that can be used to build a list of assertions.

    import { ZAssert, createError } from '@zthun/helpful-fn';

    const user = readUser();

    ZAssert
    .claim(user.name != null, 'User name is required')
    .claim(user.email != null, 'User email is required')
    .assert((m) => createError(m));
    Index

    Methods

    • Runs the assertion.

      Type Parameters

      • E extends Error

      Parameters

      • fail: (message: any) => E

        The factory that is responsible for returning the specified error to throw.

      Returns void

    • Adds a claim.

      Parameters

      • claim: boolean

        The claim predicate.

      • msg: any

        The message to add if the claim fails.

      Returns this

      This object.

    • Initializes a new instance of a ZAssert with one claim.

      Parameters

      • claim: boolean

        The claim to make.

      • msg: any

        The message to throw if the claim is false.

      Returns ZAssert

      A new ZAssert object with an initial claim.