Type alias AssertingValidator<T>

AssertingValidator<T>: T extends ReusableValidator<infer R>
    ? ((value, label?) => asserts value is R)
    : T extends BasePredicate<infer R>
        ? ((value, label?) => asserts value is R)
        : never

Turn a ReusableValidator into one with a type assertion.

Type Parameters

  • T

Example

const checkUsername = ow.create(ow.string.minLength(3));
const checkUsername_: AssertingValidator<typeof checkUsername> = checkUsername;

Example

const predicate = ow.string.minLength(3);
const checkUsername: AssertingValidator<typeof predicate> = ow.create(predicate);