Endo API documentation
    Preparing search index...
    Checker: (cond: boolean, details?: Details) => boolean

    Internal to a useful pattern for writing checking logic (a "checkFoo" function) that can be used to implement a predicate (an "isFoo" function) or a validator (an "assertFoo" function).

    • A predicate ideally only returns true or false and rarely throws.
    • A validator throws an informative diagnostic when the predicate would have returned false, and simply returns undefined normally when the predicate would have returned true.
    • The internal checking function that they share is parameterized by a Checker that determines how to proceed with a failure condition. Predicates pass in an identity function as checker. Validators pass in assertChecker which is a trivial wrapper around assert.

    See the various uses for good examples.

    Type declaration

      • (cond: boolean, details?: Details): boolean
      • Parameters

        • cond: boolean
        • Optionaldetails: Details

        Returns boolean