Assertive.ts - Core API / StaticTypeFactories
Interface: StaticTypeFactories
Encapsulates a set of predefined TypeFactory instances.
Table of contents
Properties
Methods
Properties
Boolean
• Boolean: TypeFactory
<boolean
, BooleanAssertion
>
A boolean
TypeFactory.
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:45
Date
• Date: TypeFactory
<Date
, DateAssertion
>
A Date
TypeFactory.
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:49
Function
• Function: TypeFactory
<AnyFunction
, FunctionAssertion
<AnyFunction
>>
A function
TypeFactory.
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:53
Number
• Number: TypeFactory
<number
, NumberAssertion
>
A number
TypeFactory.
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:57
String
• String: TypeFactory
<string
, StringAssertion
>
A string
TypeFactory.
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:61
Methods
array
▸ array<T
>(innerType?
): TypeFactory
<T
[], ArrayAssertion
<T
>>
Creates an array TypeFactory of the given TypeFactory.
Type parameters
Name | Description |
---|---|
T |
the type of the array |
Parameters
Name | Type | Description |
---|---|---|
innerType? |
TypeFactory <T , Assertion <T >> |
the TypeFactory for the array type |
Returns
TypeFactory
<T
[], ArrayAssertion
<T
>>
Example
TypeFactories.array(TypeFactories.String); // a `string[]` factory
TypeFactories.array(TypeFactories.Date); // a `Date[]` factory
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:73
instanceOf
▸ instanceOf<T
>(Type
): TypeFactory
<T
, Assertion
<T
>>
Creates a TypeFactory for an instance of the given constructor.
Type parameters
Name | Description |
---|---|
T |
the type of the instance constructor |
Parameters
Name | Type | Description |
---|---|---|
Type |
Constructor <T > |
the instance constructor |
Returns
TypeFactory
<T
, Assertion
<T
>>
Example
class Person { ... }
TypeFactories.instanceOf(Person); // a `Person` instance factory
TypeFactories.instanceOf(Error); // an `Error` instance factory
Defined in
packages/core/src/lib/helpers/TypeFactories.ts:88
object
▸ object<T
>(): TypeFactory
<T
, ObjectAssertion
<T
>>
Creates a TypeFactory for a Javascript Object.
Type parameters
Name | Type | Description |
---|---|---|
T |
extends Struct |
the type of the object |
Returns
TypeFactory
<T
, ObjectAssertion
<T
>>
Example
interface User {
name: string;
age: number;
}
TypeFactories.object<User>(); // a `User` object factory