Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Ow

Hierarchy

  • Modifiers
  • Predicates
    • Ow

Callable

  • Ow<T>(value: unknown, predicate: BasePredicate<T>): asserts value is T
  • Ow<T>(value: unknown, label: string, predicate: BasePredicate<T>): asserts value is T
  • Test if the value matches the predicate. Throws an ArgumentError if the test fails.

    Type parameters

    • T

    Parameters

    • value: unknown

      Value to test.

    • predicate: BasePredicate<T>

      Predicate to test against.

    Returns asserts value is T

  • Test if value matches the provided predicate. Throws an ArgumentError with the specified label if the test fails.

    Type parameters

    • T

    Parameters

    • value: unknown

      Value to test.

    • label: string

      Label which should be used in error messages.

    • predicate: BasePredicate<T>

      Predicate to test against.

    Returns asserts value is T

Index

Properties

any

any: <T1>(p1: BasePredicate<T1>) => AnyPredicate<T1> & <T1, T2>(p1: BasePredicate<T1>, p2: BasePredicate<T2>) => AnyPredicate<T1 | T2> & <T1, T2, T3>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>) => AnyPredicate<T1 | T2 | T3> & <T1, T2, T3, T4>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>) => AnyPredicate<T1 | T2 | T3 | T4> & <T1, T2, T3, T4, T5>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>) => AnyPredicate<T1 | T2 | T3 | T4 | T5> & <T1, T2, T3, T4, T5, T6>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6> & <T1, T2, T3, T4, T5, T6, T7>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7> & <T1, T2, T3, T4, T5, T6, T7, T8>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8> & <T1, T2, T3, T4, T5, T6, T7, T8, T9>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9> & <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>, p10: BasePredicate<T10>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10> & (...predicate: BasePredicate<unknown>[]) => AnyPredicate<unknown>

Test that the value matches at least one of the given predicates.

Readonly array

array: ArrayPredicate<unknown>

Test the value to be an array.

Readonly arrayBuffer

arrayBuffer: ArrayBufferPredicate<ArrayBuffer>

Test the value to be a ArrayBuffer.

Readonly boolean

Test the value to be a boolean.

Readonly buffer

buffer: Predicate<Buffer>

Test the value to be a Buffer.

create

create: <T>(predicate: BasePredicate<T>) => ReusableValidator<T> & <T>(label: string, predicate: BasePredicate<T>) => ReusableValidator<T>

Create a reusable validator.

param

Predicate used in the validator function.

Readonly dataView

Test the value to be a DataView.

Readonly date

Test the value to be a Date.

Readonly error

Test the value to be an Error.

Readonly float32Array

float32Array: TypedArrayPredicate<Float32Array>

Test the value to be a Float32Array.

Readonly float64Array

float64Array: TypedArrayPredicate<Float64Array>

Test the value to be a Float64Array.

Readonly function

function: Predicate<Function>

Test the value to be a Function.

Readonly int16Array

int16Array: TypedArrayPredicate<Int16Array>

Test the value to be a Int16Array.

Readonly int32Array

int32Array: TypedArrayPredicate<Int32Array>

Test the value to be a Int32Array.

Readonly int8Array

int8Array: TypedArrayPredicate<Int8Array>

Test the value to be a Int8Array.

isValid

isValid: <T>(value: T, predicate: BasePredicate<T>) => value is T

Returns true if the value matches the predicate, otherwise returns false.

param

Value to test.

param

Predicate to test against.

Type declaration

    • <T>(value: T, predicate: BasePredicate<T>): value is T
    • Type parameters

      • T

      Parameters

      • value: T
      • predicate: BasePredicate<T>

      Returns value is T

Readonly iterable

iterable: Predicate<Iterable<unknown>>

Test the value to be Iterable.

Readonly map

map: MapPredicate<unknown, unknown>

Test the value to be a Map.

Readonly nan

nan: Predicate<number>

Test the value to be not a number.

Readonly null

null: Predicate<null>

Test the value to be null.

Readonly nullOrUndefined

nullOrUndefined: Predicate<undefined | null>

Test the value to be null or undefined.

Readonly number

Test the value to be a number.

Readonly object

object: ObjectPredicate<object>

Test the value to be an object.

Readonly optional

optional: { any: <T1>(p1: BasePredicate<T1>) => AnyPredicate<T1> & <T1, T2>(p1: BasePredicate<T1>, p2: BasePredicate<T2>) => AnyPredicate<T1 | T2> & <T1, T2, T3>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>) => AnyPredicate<T1 | T2 | T3> & <T1, T2, T3, T4>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>) => AnyPredicate<T1 | T2 | T3 | T4> & <T1, T2, T3, T4, T5>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>) => AnyPredicate<T1 | T2 | T3 | T4 | T5> & <T1, T2, T3, T4, T5, T6>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6> & <T1, T2, T3, T4, T5, T6, T7>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7> & <T1, T2, T3, T4, T5, T6, T7, T8>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8> & <T1, T2, T3, T4, T5, T6, T7, T8, T9>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9> & <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>, p10: BasePredicate<T10>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10> & (...predicate: BasePredicate<unknown>[]) => AnyPredicate<unknown>; array: ArrayPredicate<unknown> & BasePredicate<undefined | unknown[]>; arrayBuffer: ArrayBufferPredicate<ArrayBuffer> & BasePredicate<undefined | ArrayBuffer>; boolean: BooleanPredicate & BasePredicate<undefined | boolean>; buffer: Predicate<Buffer> & BasePredicate<undefined | Buffer>; dataView: DataViewPredicate & BasePredicate<undefined | DataView>; date: DatePredicate & BasePredicate<undefined | Date>; error: ErrorPredicate & BasePredicate<undefined | Error>; float32Array: TypedArrayPredicate<Float32Array> & BasePredicate<undefined | Float32Array>; float64Array: TypedArrayPredicate<Float64Array> & BasePredicate<undefined | Float64Array>; function: Predicate<Function> & BasePredicate<undefined | Function>; int16Array: TypedArrayPredicate<Int16Array> & BasePredicate<undefined | Int16Array>; int32Array: TypedArrayPredicate<Int32Array> & BasePredicate<undefined | Int32Array>; int8Array: TypedArrayPredicate<Int8Array> & BasePredicate<undefined | Int8Array>; iterable: Predicate<Iterable<unknown>> & BasePredicate<undefined | Iterable<unknown>>; map: MapPredicate<unknown, unknown> & BasePredicate<undefined | Map<unknown, unknown>>; nan: Predicate<number> & BasePredicate<undefined | number>; null: Predicate<null> & BasePredicate<undefined | null>; nullOrUndefined: Predicate<undefined | null> & BasePredicate<undefined | null>; number: NumberPredicate & BasePredicate<undefined | number>; object: ObjectPredicate<object> & BasePredicate<undefined | object>; promise: Predicate<Promise<unknown>> & BasePredicate<undefined | Promise<unknown>>; regExp: Predicate<RegExp> & BasePredicate<undefined | RegExp>; set: SetPredicate<any> & BasePredicate<undefined | Set<any>>; sharedArrayBuffer: ArrayBufferPredicate<SharedArrayBuffer> & BasePredicate<undefined | SharedArrayBuffer>; string: StringPredicate & BasePredicate<undefined | string>; symbol: Predicate<symbol> & BasePredicate<undefined | symbol>; typedArray: TypedArrayPredicate<TypedArray> & BasePredicate<undefined | Uint8Array | Int8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array>; uint16Array: TypedArrayPredicate<Uint16Array> & BasePredicate<undefined | Uint16Array>; uint32Array: TypedArrayPredicate<Uint32Array> & BasePredicate<undefined | Uint32Array>; uint8Array: TypedArrayPredicate<Uint8Array> & BasePredicate<undefined | Uint8Array>; uint8ClampedArray: TypedArrayPredicate<Uint8ClampedArray> & BasePredicate<undefined | Uint8ClampedArray>; undefined: Predicate<undefined> & BasePredicate<undefined>; weakMap: WeakMapPredicate<object> & BasePredicate<undefined | WeakMap<object, unknown>>; weakSet: WeakSetPredicate<object> & BasePredicate<undefined | WeakSet<object>> }

Make the following predicate optional so it doesn't fail when the value is undefined.

Type declaration

  • any: <T1>(p1: BasePredicate<T1>) => AnyPredicate<T1> & <T1, T2>(p1: BasePredicate<T1>, p2: BasePredicate<T2>) => AnyPredicate<T1 | T2> & <T1, T2, T3>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>) => AnyPredicate<T1 | T2 | T3> & <T1, T2, T3, T4>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>) => AnyPredicate<T1 | T2 | T3 | T4> & <T1, T2, T3, T4, T5>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>) => AnyPredicate<T1 | T2 | T3 | T4 | T5> & <T1, T2, T3, T4, T5, T6>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6> & <T1, T2, T3, T4, T5, T6, T7>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7> & <T1, T2, T3, T4, T5, T6, T7, T8>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8> & <T1, T2, T3, T4, T5, T6, T7, T8, T9>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9> & <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>, p10: BasePredicate<T10>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10> & (...predicate: BasePredicate<unknown>[]) => AnyPredicate<unknown>

    Test that the value matches at least one of the given predicates.

  • Readonly array: ArrayPredicate<unknown> & BasePredicate<undefined | unknown[]>

    Test the value to be an array.

  • Readonly arrayBuffer: ArrayBufferPredicate<ArrayBuffer> & BasePredicate<undefined | ArrayBuffer>

    Test the value to be a ArrayBuffer.

  • Readonly boolean: BooleanPredicate & BasePredicate<undefined | boolean>

    Test the value to be a boolean.

  • Readonly buffer: Predicate<Buffer> & BasePredicate<undefined | Buffer>

    Test the value to be a Buffer.

  • Readonly dataView: DataViewPredicate & BasePredicate<undefined | DataView>

    Test the value to be a DataView.

  • Readonly date: DatePredicate & BasePredicate<undefined | Date>

    Test the value to be a Date.

  • Readonly error: ErrorPredicate & BasePredicate<undefined | Error>

    Test the value to be an Error.

  • Readonly float32Array: TypedArrayPredicate<Float32Array> & BasePredicate<undefined | Float32Array>

    Test the value to be a Float32Array.

  • Readonly float64Array: TypedArrayPredicate<Float64Array> & BasePredicate<undefined | Float64Array>

    Test the value to be a Float64Array.

  • Readonly function: Predicate<Function> & BasePredicate<undefined | Function>

    Test the value to be a Function.

  • Readonly int16Array: TypedArrayPredicate<Int16Array> & BasePredicate<undefined | Int16Array>

    Test the value to be a Int16Array.

  • Readonly int32Array: TypedArrayPredicate<Int32Array> & BasePredicate<undefined | Int32Array>

    Test the value to be a Int32Array.

  • Readonly int8Array: TypedArrayPredicate<Int8Array> & BasePredicate<undefined | Int8Array>

    Test the value to be a Int8Array.

  • Readonly iterable: Predicate<Iterable<unknown>> & BasePredicate<undefined | Iterable<unknown>>

    Test the value to be Iterable.

  • Readonly map: MapPredicate<unknown, unknown> & BasePredicate<undefined | Map<unknown, unknown>>

    Test the value to be a Map.

  • Readonly nan: Predicate<number> & BasePredicate<undefined | number>

    Test the value to be not a number.

  • Readonly null: Predicate<null> & BasePredicate<undefined | null>

    Test the value to be null.

  • Readonly nullOrUndefined: Predicate<undefined | null> & BasePredicate<undefined | null>

    Test the value to be null or undefined.

  • Readonly number: NumberPredicate & BasePredicate<undefined | number>

    Test the value to be a number.

  • Readonly object: ObjectPredicate<object> & BasePredicate<undefined | object>

    Test the value to be an object.

  • Readonly promise: Predicate<Promise<unknown>> & BasePredicate<undefined | Promise<unknown>>

    Test the value to be a Promise.

  • Readonly regExp: Predicate<RegExp> & BasePredicate<undefined | RegExp>

    Test the value to be a RegExp.

  • Readonly set: SetPredicate<any> & BasePredicate<undefined | Set<any>>

    Test the value to be a Set.

  • Readonly sharedArrayBuffer: ArrayBufferPredicate<SharedArrayBuffer> & BasePredicate<undefined | SharedArrayBuffer>

    Test the value to be a SharedArrayBuffer.

  • Readonly string: StringPredicate & BasePredicate<undefined | string>

    Test the value to be a string.

  • Readonly symbol: Predicate<symbol> & BasePredicate<undefined | symbol>

    Test the value to be a Symbol.

  • Readonly typedArray: TypedArrayPredicate<TypedArray> & BasePredicate<undefined | Uint8Array | Int8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array>

    Test the value to be a typed array.

  • Readonly uint16Array: TypedArrayPredicate<Uint16Array> & BasePredicate<undefined | Uint16Array>

    Test the value to be a Uint16Array.

  • Readonly uint32Array: TypedArrayPredicate<Uint32Array> & BasePredicate<undefined | Uint32Array>

    Test the value to be a Uint32Array.

  • Readonly uint8Array: TypedArrayPredicate<Uint8Array> & BasePredicate<undefined | Uint8Array>

    Test the value to be a Uint8Array.

  • Readonly uint8ClampedArray: TypedArrayPredicate<Uint8ClampedArray> & BasePredicate<undefined | Uint8ClampedArray>

    Test the value to be a Uint8ClampedArray.

  • Readonly undefined: Predicate<undefined> & BasePredicate<undefined>

    Test the value to be undefined.

  • Readonly weakMap: WeakMapPredicate<object> & BasePredicate<undefined | WeakMap<object, unknown>>

    Test the value to be a WeakMap.

  • Readonly weakSet: WeakSetPredicate<object> & BasePredicate<undefined | WeakSet<object>>

    Test the value to be a WeakSet.

Readonly promise

promise: Predicate<Promise<unknown>>

Test the value to be a Promise.

Readonly regExp

regExp: Predicate<RegExp>

Test the value to be a RegExp.

Readonly set

set: SetPredicate<any>

Test the value to be a Set.

Readonly sharedArrayBuffer

sharedArrayBuffer: ArrayBufferPredicate<SharedArrayBuffer>

Test the value to be a SharedArrayBuffer.

Readonly string

Test the value to be a string.

Readonly symbol

symbol: Predicate<symbol>

Test the value to be a Symbol.

Readonly typedArray

typedArray: TypedArrayPredicate<TypedArray>

Test the value to be a typed array.

Readonly uint16Array

uint16Array: TypedArrayPredicate<Uint16Array>

Test the value to be a Uint16Array.

Readonly uint32Array

uint32Array: TypedArrayPredicate<Uint32Array>

Test the value to be a Uint32Array.

Readonly uint8Array

uint8Array: TypedArrayPredicate<Uint8Array>

Test the value to be a Uint8Array.

Readonly uint8ClampedArray

uint8ClampedArray: TypedArrayPredicate<Uint8ClampedArray>

Test the value to be a Uint8ClampedArray.

Readonly undefined

undefined: Predicate<undefined>

Test the value to be undefined.

Readonly weakMap

weakMap: WeakMapPredicate<object>

Test the value to be a WeakMap.

Readonly weakSet

weakSet: WeakSetPredicate<object>

Test the value to be a WeakSet.