API reference › @evolu/common › Type
Runtime types.
Core Types
| Name | Description |
|---|---|
| AnyType | Any concrete Type, regardless of its particular type parameters. |
| EvoluTypeError | Error returned when a value is not an Evolu Type. |
| NeverError | A plain structured error produced by a Type operation. |
| Type | A runtime representation of a TypeScript type with typed structured errors. |
| TypeError | A plain structured error produced by a Type operation. |
| TypeNode | - |
| TypeValueError | A structured error that directly describes a rejected value. |
| ValidationOptions | Configures how container Type operations report errors. |
| TypeErrorFormatter | Formats a structured TypeError as a human-readable message. |
| TypeName | - |
| assertType | Asserts that a value belongs to a Type Output domain. |
| EvoluType | An Evolu Type validating other Evolu Types. |
Type construction
| Name | Description |
|---|---|
| BrandType | - |
| TransformOutputError | Wraps an error produced by the output Type of transform. |
| TransformType | - |
| BrandFactory | Reusable factory for creating a Type with a Brand. |
| TransformError | - |
| brand | Branded Type. |
| createType | Custom Type. |
| transform | Transform Type. |
Base Types
| Name | Description |
|---|---|
| InstanceOfError | - |
| InstanceOfType | - |
| ObjectTag | Nominal evidence that a value has one object tag. |
| ObjectTagError | An error returned when an object does not report the expected tag. |
| ObjectTagType | The Type returned by objectTag. |
| TypeOfError | - |
| InstanceConstructor | A JavaScript class constructor accepted by instanceOf. |
| ArrayBuffer | A realm-neutral JavaScript ArrayBuffer Type for trusted values. |
| BigInt | - |
| Boolean | - |
| Date | A realm-neutral JavaScript Date Type for trusted values. |
| Function | - |
| Never | - |
| Object | A Type for readonly plain objects with unknown property values. |
| Symbol | - |
| Uint8Array | A realm-neutral JavaScript Uint8Array Type for trusted values. |
| Unknown | - |
| instanceOf | Creates a Type for instances of one constructor. |
| objectTag | Creates a realm-neutral Type that trusts an object's reported tag. |
String
| Name | Description |
|---|---|
| Base64UrlError | - |
| CapitalizedError | - |
| DateIsoError | - |
| DateIsoFromDateError | - |
| IdError | - |
| MnemonicError | - |
| NameError | - |
| RegexError | - |
| TableId | - |
| TableIdError | - |
| TrimmedError | - |
| Base64Url | Base64Url text without padding. |
| CapitalizedString | Capitalized String. |
| DateIso | Canonical ISO date-time String. |
| Id | Evolu Id: 16 bytes encoded as a 22-character Base64Url. |
| IdBytes | Binary representation of an Id. |
| Mnemonic | A valid English BIP39 mnemonic. |
| Name | A non-empty URL-safe name containing at most 64 UTF-16 code units. |
| NonEmptyTrimmedString | A non-empty TrimmedString. |
| NonEmptyTrimmedString100 | A NonEmptyTrimmedString with at most 100 UTF-16 code units. |
| NonEmptyTrimmedString1000 | A NonEmptyTrimmedString with at most 1,000 UTF-16 code units. |
| SimplePassword | A trimmed password containing between 8 and 64 UTF-16 code units. |
| TrimmedString | A String without surrounding whitespace. |
| UrlSafeString | Non-empty URL-safe String. |
| Base64Url | Base64Url text without padding. |
| capitalized | Capitalized Brand. |
| CapitalizedString | Capitalized String. |
| DateIso | Canonical ISO date-time String. |
| DateIsoFromDate | Safely transforms a Date into a canonical DateIso. |
| Id | Evolu Id: 16 bytes encoded as a 22-character Base64Url. |
| IdBytes | Binary representation of an Id. |
| idBytesTypeValueLength | - |
| Mnemonic | A valid English BIP39 mnemonic. |
| Name | A non-empty URL-safe name containing at most 64 UTF-16 code units. |
| NonEmptyTrimmedString | A non-empty TrimmedString. |
| NonEmptyTrimmedString100 | A NonEmptyTrimmedString with at most 100 UTF-16 code units. |
| NonEmptyTrimmedString1000 | A NonEmptyTrimmedString with at most 1,000 UTF-16 code units. |
| SimplePassword | A trimmed password containing between 8 and 64 UTF-16 code units. |
| String | A JavaScript string Type without additional constraints. |
| testName | Stable valid Name for tests and internal fixtures. |
| trimmed | Adds a Brand requiring a string without surrounding whitespace. |
| TrimmedString | A String without surrounding whitespace. |
| UrlSafeString | Non-empty URL-safe String. |
| base64UrlToUint8Array | Decodes Base64Url as bytes. |
| createId | Creates a cryptographically random Id. |
| createIdAsUuidv7 | Creates an Id whose bytes use the UUID v7 timestamp layout. |
| createIdFromString | Deterministically creates an Id from the first 16 SHA-256 bytes. |
| id | A table-specific Id Type. |
| idBytesToId | - |
| idToIdBytes | - |
| length | Adds a Brand requiring a value to have exactly exact items. |
| maxLength | Adds a Brand requiring a value to have at most max items. |
| minLength | Adds a Brand requiring a value to have at least min items. |
| regex | Creates a string Brand that must match a regular expression. |
| trim | Trims a string and returns a TrimmedString. |
| uint8ArrayToBase64Url | Encodes bytes as Base64Url. |
Number
| Name | Description |
|---|---|
| BetweenError | - |
| FiniteError | - |
| GreaterThanError | - |
| GreaterThanOrEqualToError | - |
| Int64Error | - |
| Int64StringError | - |
| IntError | - |
| LessThanError | - |
| LessThanOrEqualToError | - |
| MultipleOfError | - |
| NegativeError | - |
| NonNaNError | - |
| NonNegativeError | - |
| NonPositiveError | - |
| PositiveDecimalStringError | - |
| PositiveError | - |
| UInt64Error | - |
| Age | A person's age as a NonNegativeInt less than 200. |
| FiniteNumber | Finite Number. |
| Int | Safe integer FiniteNumber. |
| Int0To100OrNonNegativeInt | 0-100 as a literal, or any already-validated NonNegativeInt. |
| Int1To100OrPositiveInt | 1-100 as a literal, or any already-validated PositiveInt. |
| Int64 | Signed 64-bit BigInt. |
| Int64String | Decimal string representation of a signed Int64. |
| NegativeInt | Negative Int. |
| NegativeNumber | Negative Number. |
| NonNaNNumber | Number other than NaN; infinities are allowed. |
| NonNegativeFiniteNumber | Non-negative FiniteNumber. |
| NonNegativeInt | Non-negative Int. |
| NonNegativeNumber | Non-negative Number. |
| NonPositiveInt | Non-positive Int. |
| NonPositiveNumber | Non-positive Number. |
| PositiveDecimalString | Canonical string representation of a positive base-10 decimal. |
| PositiveInt | Positive Int. |
| PositiveNumber | Positive Number. |
| Ratio | Finite Number from zero to one, inclusive. |
| UInt64 | Unsigned 64-bit BigInt. |
| Age | A person's age as a NonNegativeInt less than 200. |
| finite | Adds a Brand requiring a finite number. |
| FiniteNumber | Finite Number. |
| int | Safe integer Brand. |
| Int | Safe integer FiniteNumber. |
| Int64 | Signed 64-bit BigInt. |
| Int64FromInt64String | Transforms an Int64String into an Int64. |
| Int64String | Decimal string representation of a signed Int64. |
| maxPositiveInt | Maximum PositiveInt value. |
| negative | Adds a Brand requiring a number less than zero. |
| NegativeInt | Negative Int. |
| NegativeNumber | Negative Number. |
| nonNaN | Adds a Brand requiring a number other than NaN. |
| NonNaNNumber | Number other than NaN; infinities are allowed. |
| nonNegative | Adds a Brand requiring a number greater than or equal to zero. |
| NonNegativeFiniteNumber | Non-negative FiniteNumber. |
| NonNegativeInt | Non-negative Int. |
| NonNegativeNumber | Non-negative Number. |
| nonPositive | Adds a Brand requiring a number less than or equal to zero. |
| NonPositiveInt | Non-positive Int. |
| NonPositiveNumber | Non-positive Number. |
| Number | A JavaScript number, including NaN, Infinity, and -Infinity. |
| onePositiveInt | Minimum PositiveInt value. |
| positive | Adds a Brand requiring a number greater than zero. |
| PositiveDecimalString | Canonical string representation of a positive base-10 decimal. |
| PositiveInt | Positive Int. |
| PositiveNumber | Positive Number. |
| Ratio | Finite Number from zero to one, inclusive. |
| UInt64 | Unsigned 64-bit BigInt. |
| zeroNonNegativeInt | Minimum NonNegativeInt value. |
| between | Adds a Brand requiring a number to be within an inclusive range. |
| greaterThan | Adds a Brand requiring a number greater than min. |
| greaterThanOrEqualTo | Adds a Brand requiring a number greater than or equal to min. |
| lessThan | Adds a Brand requiring a number less than max. |
| lessThanOrEqualTo | Adds a Brand requiring a number less than or equal to max. |
| multipleOf | Adds a Brand requiring a number to be a multiple of an exact decimal divisor. |
Collection
| Name | Description |
|---|---|
| ArrayAccessorIssue | - |
| ArrayExcessPropertyIssue | - |
| ArrayHoleIssue | - |
| ArrayNotArrayError | - |
| ArrayType | - |
| LengthError | - |
| MaxLengthError | - |
| MinLengthError | - |
| SetExcessPropertyIssue | - |
| SetNotSetError | - |
| SetType | - |
| SetUnexpectedPrototypeError | An error returned when a set input is a Set subclass. |
| TupleAccessorIssue | An accessor element in a tuple. |
| TupleExcessPropertyIssue | An undeclared own property in a tuple. |
| TupleHoleIssue | A missing indexed element in a tuple. |
| TupleInvalidLengthError | An error returned when a tuple input has the wrong length. |
| TupleNotArrayError | An error returned when a tuple input is not an Array. |
| TupleType | The fixed-length heterogeneous Type returned by tuple. |
| ArrayElementIssue | - |
| ArrayElementsError | - |
| ArrayError | - |
| ArrayIssue | - |
| ArrayItemsError | - |
| SetElementIssue | - |
| SetElementsError | - |
| SetError | - |
| SetItemsError | - |
| TupleElementIssue | An error returned by one element Type in a tuple. |
| TupleElementsError | Element errors possible after a typed tuple boundary was asserted. |
| TupleError | An error returned while validating a tuple. |
| TupleIssue | One structural or element issue found in a tuple. |
| TupleItemsError | An error containing structural or element issues found in a tuple. |
| array | Array Type. |
| length | Adds a Brand requiring a value to have exactly exact items. |
| maxLength | Adds a Brand requiring a value to have at most max items. |
| minLength | Adds a Brand requiring a value to have at least min items. |
| set | Set Type whose every element must match one Type. |
| tuple | Tuple Type. |
Objects
| Name | Description |
|---|---|
| ObjectError | An error returned while validating an object and its properties. |
| ObjectExcessPropertyError | An error returned for an input property outside an Object Type's allowed key domain. |
| ObjectMissingPropertyError | An error returned when a required object property is absent. |
| ObjectNotObjectError | An error returned when an object input is not an object. |
| ObjectPropertiesError | An error returned while validating the properties of an object. |
| ObjectPropertyAccessError | An error returned when a present object property is not represented as an enumerable data property. |
| ObjectUnexpectedPrototypeError | An error returned when an object input falls outside its supported plain-object prototype boundary. |
| OptionalProperty | An optional property used to construct an object Type. |
| RecordAccessorIssue | An accessor property rejected by record. |
| RecordCollisionIssue | - |
| RecordNonEnumerableIssue | A non-enumerable property rejected by record. |
| RecordNotPlainRecordError | - |
| RecordNotRecordError | - |
| RecordType | - |
| NullableToOptionalProps | - |
| ObjectProps | Properties used to construct an object Type. |
| ObjectType | - |
| PartialObjectProps | - |
| RecordEntriesError | Entry errors returned by a record operation. |
| RecordError | - |
| RecordIssue | - |
| RecordKeyIssue | - |
| RecordStructuralIssue | - |
| RecordValueIssue | - |
| nullableToOptional | Makes every property whose Union Type includes Null optional. |
| object | Plain object Type. |
| omit | Creates an object Type without the selected declared properties. |
| optional | Optional object property. |
| partial | Creates an object Type with every property optional. |
| record | Record Type. |
Unions
| Name | Description |
|---|---|
| LiteralError | - |
| LiteralType | - |
| UnionMemberError | - |
| UnionType | - |
| UnionError | - |
| UnionInputType | A root Type validating the encoded Inputs accepted by union. |
| Null | - |
| Undefined | - |
| literal | Literal Type. |
| nullishOr | Shorthand for passing a Type, null, and undefined to union. |
| nullOr | Shorthand for passing a Type and null to union. |
| undefinedOr | Shorthand for passing a Type and undefined to union. |
| union | Union Type. |
Discriminated unions
| Name | Description |
|---|---|
| DiscriminatedUnionDiscriminatorError | An error returned when no member of discriminatedUnion matches. |
| DiscriminatedUnionMemberIssue | A selected-member issue returned by discriminatedUnion. |
| DiscriminatedUnionObjectError | An error returned when a value cannot be routed through Object. |
| DiscriminatedUnionPropertyAccessError | An error returned when the discriminator for discriminatedUnion is not an own enumerable data property. |
| DiscriminatedUnionType | The routed Type returned by discriminatedUnion. |
| Typed | A structurally tagged value created by typed. |
| DiscriminatedUnionError | An error returned while selecting a member in discriminatedUnion. |
| DiscriminatedUnionInputType | A root Type validating Inputs accepted by discriminatedUnion. |
| DiscriminatedUnionMemberError | An error returned by the member selected by discriminatedUnion. |
| ExtractTyped | Extracts members of a Typed Output union by their type literal. |
| TypedType | The ObjectType returned by typed. |
| discriminatedUnion | Discriminated Union Type. |
| typed | Tagged ObjectType. |
Results
| Name | Description |
|---|---|
| UnknownNextResult | A nextResult Type with unknown value, error, and done components. |
| UnknownResult | A result Type for Result<unknown, unknown>. |
| UnknownNextResult | A nextResult Type with unknown value, error, and done components. |
| UnknownResult | A result Type for Result<unknown, unknown>. |
| nextResult | Creates a Type for a producer's value, error, or done Result. |
| result | Creates a Type for Result values. |
Recursive Types
| Name | Description |
|---|---|
| LazyType | A deferred Type with an explicit recursive type declaration. |
| lazy | Lazy Type for recursive definitions. |
JSON
| Name | Description |
|---|---|
| JsonError | An error returned when a string does not contain valid JSON text. |
| JsonObject | An exact JSON object containing only JsonValue properties. |
| JsonObjectInput | A candidate JSON object before exact runtime validation. |
| JsonObjectType | The exact top-level JSON object Type. |
| JsonValueError | An error containing one or more issues found in a JsonValue. |
| JsonValueType | The exact root Type of in-memory JSON data values. |
| Json | A String Brand proving that its exact text parses to JsonValue. |
| JsonArray | An exact JSON array containing only JsonValue elements. |
| JsonArrayInput | A candidate JSON array before exact runtime validation. |
| JsonValue | An exact in-memory JSON data value. |
| JsonValueInput | A candidate JSON value before exact runtime validation. |
| JsonValueIssue | One issue found while validating an exact JsonValue. |
| Json | A String Brand proving that its exact text parses to JsonValue. |
| JsonArray | Exact top-level JSON array Type. |
| JsonObject | Exact top-level JSON object Type. |
| JsonValue | Exact root Type for JsonValue data trees. |
| JsonValueFromJson | Json to JsonValue transformation. |
| json | Creates a branded Json Type and total conversions for another Type. |
| jsonToJsonValue | Totally parses proven Json text into an exact JsonValue. |
| jsonValueToJson | Totally encodes an exact JsonValue as canonical Json text. |
Localization
| Variable | Description |
|---|---|
| localizeTypes | Creates localized copies of selected Types for every locale. |
Type utilities
| Type Alias | Description |
|---|---|
| InferErrors | The union of errors a Type can return from fromUnknown. |
| InferType | Extracts the Output of a Type. |
| ValidateBrandFactoryNumber | Numeric parameter preserving literal types in a BrandFactory. |