API reference@evolu/common › Type

Runtime types.

Core Types

NameDescription
AnyTypeAny concrete Type, regardless of its particular type parameters.
EvoluTypeErrorError returned when a value is not an Evolu Type.
NeverErrorA plain structured error produced by a Type operation.
TypeA runtime representation of a TypeScript type with typed structured errors.
TypeErrorA plain structured error produced by a Type operation.
TypeNode-
TypeValueErrorA structured error that directly describes a rejected value.
ValidationOptionsConfigures how container Type operations report errors.
TypeErrorFormatterFormats a structured TypeError as a human-readable message.
TypeName-
assertTypeAsserts that a value belongs to a Type Output domain.
EvoluTypeAn Evolu Type validating other Evolu Types.

Type construction

NameDescription
BrandType-
TransformOutputErrorWraps an error produced by the output Type of transform.
TransformType-
BrandFactoryReusable factory for creating a Type with a Brand.
TransformError-
brandBranded Type.
createTypeCustom Type.
transformTransform Type.

Base Types

NameDescription
InstanceOfError-
InstanceOfType-
ObjectTagNominal evidence that a value has one object tag.
ObjectTagErrorAn error returned when an object does not report the expected tag.
ObjectTagTypeThe Type returned by objectTag.
TypeOfError-
InstanceConstructorA JavaScript class constructor accepted by instanceOf.
ArrayBufferA realm-neutral JavaScript ArrayBuffer Type for trusted values.
BigInt-
Boolean-
DateA realm-neutral JavaScript Date Type for trusted values.
Function-
Never-
ObjectA Type for readonly plain objects with unknown property values.
Symbol-
Uint8ArrayA realm-neutral JavaScript Uint8Array Type for trusted values.
Unknown-
instanceOfCreates a Type for instances of one constructor.
objectTagCreates a realm-neutral Type that trusts an object's reported tag.

String

NameDescription
Base64UrlError-
CapitalizedError-
DateIsoError-
DateIsoFromDateError-
IdError-
MnemonicError-
NameError-
RegexError-
TableId-
TableIdError-
TrimmedError-
Base64UrlBase64Url text without padding.
CapitalizedStringCapitalized String.
DateIsoCanonical ISO date-time String.
IdEvolu Id: 16 bytes encoded as a 22-character Base64Url.
IdBytesBinary representation of an Id.
MnemonicA valid English BIP39 mnemonic.
NameA non-empty URL-safe name containing at most 64 UTF-16 code units.
NonEmptyTrimmedStringA non-empty TrimmedString.
NonEmptyTrimmedString100A NonEmptyTrimmedString with at most 100 UTF-16 code units.
NonEmptyTrimmedString1000A NonEmptyTrimmedString with at most 1,000 UTF-16 code units.
SimplePasswordA trimmed password containing between 8 and 64 UTF-16 code units.
TrimmedStringA String without surrounding whitespace.
UrlSafeStringNon-empty URL-safe String.
Base64UrlBase64Url text without padding.
capitalizedCapitalized Brand.
CapitalizedStringCapitalized String.
DateIsoCanonical ISO date-time String.
DateIsoFromDateSafely transforms a Date into a canonical DateIso.
IdEvolu Id: 16 bytes encoded as a 22-character Base64Url.
IdBytesBinary representation of an Id.
idBytesTypeValueLength-
MnemonicA valid English BIP39 mnemonic.
NameA non-empty URL-safe name containing at most 64 UTF-16 code units.
NonEmptyTrimmedStringA non-empty TrimmedString.
NonEmptyTrimmedString100A NonEmptyTrimmedString with at most 100 UTF-16 code units.
NonEmptyTrimmedString1000A NonEmptyTrimmedString with at most 1,000 UTF-16 code units.
SimplePasswordA trimmed password containing between 8 and 64 UTF-16 code units.
StringA JavaScript string Type without additional constraints.
testNameStable valid Name for tests and internal fixtures.
trimmedAdds a Brand requiring a string without surrounding whitespace.
TrimmedStringA String without surrounding whitespace.
UrlSafeStringNon-empty URL-safe String.
base64UrlToUint8ArrayDecodes Base64Url as bytes.
createIdCreates a cryptographically random Id.
createIdAsUuidv7Creates an Id whose bytes use the UUID v7 timestamp layout.
createIdFromStringDeterministically creates an Id from the first 16 SHA-256 bytes.
idA table-specific Id Type.
idBytesToId-
idToIdBytes-
lengthAdds a Brand requiring a value to have exactly exact items.
maxLengthAdds a Brand requiring a value to have at most max items.
minLengthAdds a Brand requiring a value to have at least min items.
regexCreates a string Brand that must match a regular expression.
trimTrims a string and returns a TrimmedString.
uint8ArrayToBase64UrlEncodes bytes as Base64Url.

Number

NameDescription
BetweenError-
FiniteError-
GreaterThanError-
GreaterThanOrEqualToError-
Int64Error-
Int64StringError-
IntError-
LessThanError-
LessThanOrEqualToError-
MultipleOfError-
NegativeError-
NonNaNError-
NonNegativeError-
NonPositiveError-
PositiveDecimalStringError-
PositiveError-
UInt64Error-
AgeA person's age as a NonNegativeInt less than 200.
FiniteNumberFinite Number.
IntSafe integer FiniteNumber.
Int0To100OrNonNegativeInt0-100 as a literal, or any already-validated NonNegativeInt.
Int1To100OrPositiveInt1-100 as a literal, or any already-validated PositiveInt.
Int64Signed 64-bit BigInt.
Int64StringDecimal string representation of a signed Int64.
NegativeIntNegative Int.
NegativeNumberNegative Number.
NonNaNNumberNumber other than NaN; infinities are allowed.
NonNegativeFiniteNumberNon-negative FiniteNumber.
NonNegativeIntNon-negative Int.
NonNegativeNumberNon-negative Number.
NonPositiveIntNon-positive Int.
NonPositiveNumberNon-positive Number.
PositiveDecimalStringCanonical string representation of a positive base-10 decimal.
PositiveIntPositive Int.
PositiveNumberPositive Number.
RatioFinite Number from zero to one, inclusive.
UInt64Unsigned 64-bit BigInt.
AgeA person's age as a NonNegativeInt less than 200.
finiteAdds a Brand requiring a finite number.
FiniteNumberFinite Number.
intSafe integer Brand.
IntSafe integer FiniteNumber.
Int64Signed 64-bit BigInt.
Int64FromInt64StringTransforms an Int64String into an Int64.
Int64StringDecimal string representation of a signed Int64.
maxPositiveIntMaximum PositiveInt value.
negativeAdds a Brand requiring a number less than zero.
NegativeIntNegative Int.
NegativeNumberNegative Number.
nonNaNAdds a Brand requiring a number other than NaN.
NonNaNNumberNumber other than NaN; infinities are allowed.
nonNegativeAdds a Brand requiring a number greater than or equal to zero.
NonNegativeFiniteNumberNon-negative FiniteNumber.
NonNegativeIntNon-negative Int.
NonNegativeNumberNon-negative Number.
nonPositiveAdds a Brand requiring a number less than or equal to zero.
NonPositiveIntNon-positive Int.
NonPositiveNumberNon-positive Number.
NumberA JavaScript number, including NaN, Infinity, and -Infinity.
onePositiveIntMinimum PositiveInt value.
positiveAdds a Brand requiring a number greater than zero.
PositiveDecimalStringCanonical string representation of a positive base-10 decimal.
PositiveIntPositive Int.
PositiveNumberPositive Number.
RatioFinite Number from zero to one, inclusive.
UInt64Unsigned 64-bit BigInt.
zeroNonNegativeIntMinimum NonNegativeInt value.
betweenAdds a Brand requiring a number to be within an inclusive range.
greaterThanAdds a Brand requiring a number greater than min.
greaterThanOrEqualToAdds a Brand requiring a number greater than or equal to min.
lessThanAdds a Brand requiring a number less than max.
lessThanOrEqualToAdds a Brand requiring a number less than or equal to max.
multipleOfAdds a Brand requiring a number to be a multiple of an exact decimal divisor.

Collection

NameDescription
ArrayAccessorIssue-
ArrayExcessPropertyIssue-
ArrayHoleIssue-
ArrayNotArrayError-
ArrayType-
LengthError-
MaxLengthError-
MinLengthError-
SetExcessPropertyIssue-
SetNotSetError-
SetType-
SetUnexpectedPrototypeErrorAn error returned when a set input is a Set subclass.
TupleAccessorIssueAn accessor element in a tuple.
TupleExcessPropertyIssueAn undeclared own property in a tuple.
TupleHoleIssueA missing indexed element in a tuple.
TupleInvalidLengthErrorAn error returned when a tuple input has the wrong length.
TupleNotArrayErrorAn error returned when a tuple input is not an Array.
TupleTypeThe fixed-length heterogeneous Type returned by tuple.
ArrayElementIssue-
ArrayElementsError-
ArrayError-
ArrayIssue-
ArrayItemsError-
SetElementIssue-
SetElementsError-
SetError-
SetItemsError-
TupleElementIssueAn error returned by one element Type in a tuple.
TupleElementsErrorElement errors possible after a typed tuple boundary was asserted.
TupleErrorAn error returned while validating a tuple.
TupleIssueOne structural or element issue found in a tuple.
TupleItemsErrorAn error containing structural or element issues found in a tuple.
arrayArray Type.
lengthAdds a Brand requiring a value to have exactly exact items.
maxLengthAdds a Brand requiring a value to have at most max items.
minLengthAdds a Brand requiring a value to have at least min items.
setSet Type whose every element must match one Type.
tupleTuple Type.

Objects

NameDescription
ObjectErrorAn error returned while validating an object and its properties.
ObjectExcessPropertyErrorAn error returned for an input property outside an Object Type's allowed key domain.
ObjectMissingPropertyErrorAn error returned when a required object property is absent.
ObjectNotObjectErrorAn error returned when an object input is not an object.
ObjectPropertiesErrorAn error returned while validating the properties of an object.
ObjectPropertyAccessErrorAn error returned when a present object property is not represented as an enumerable data property.
ObjectUnexpectedPrototypeErrorAn error returned when an object input falls outside its supported plain-object prototype boundary.
OptionalPropertyAn optional property used to construct an object Type.
RecordAccessorIssueAn accessor property rejected by record.
RecordCollisionIssue-
RecordNonEnumerableIssueA non-enumerable property rejected by record.
RecordNotPlainRecordError-
RecordNotRecordError-
RecordType-
NullableToOptionalProps-
ObjectPropsProperties used to construct an object Type.
ObjectType-
PartialObjectProps-
RecordEntriesErrorEntry errors returned by a record operation.
RecordError-
RecordIssue-
RecordKeyIssue-
RecordStructuralIssue-
RecordValueIssue-
nullableToOptionalMakes every property whose Union Type includes Null optional.
objectPlain object Type.
omitCreates an object Type without the selected declared properties.
optionalOptional object property.
partialCreates an object Type with every property optional.
recordRecord Type.

Unions

NameDescription
LiteralError-
LiteralType-
UnionMemberError-
UnionType-
UnionError-
UnionInputTypeA root Type validating the encoded Inputs accepted by union.
Null-
Undefined-
literalLiteral Type.
nullishOrShorthand for passing a Type, null, and undefined to union.
nullOrShorthand for passing a Type and null to union.
undefinedOrShorthand for passing a Type and undefined to union.
unionUnion Type.

Discriminated unions

NameDescription
DiscriminatedUnionDiscriminatorErrorAn error returned when no member of discriminatedUnion matches.
DiscriminatedUnionMemberIssueA selected-member issue returned by discriminatedUnion.
DiscriminatedUnionObjectErrorAn error returned when a value cannot be routed through Object.
DiscriminatedUnionPropertyAccessErrorAn error returned when the discriminator for discriminatedUnion is not an own enumerable data property.
DiscriminatedUnionTypeThe routed Type returned by discriminatedUnion.
TypedA structurally tagged value created by typed.
DiscriminatedUnionErrorAn error returned while selecting a member in discriminatedUnion.
DiscriminatedUnionInputTypeA root Type validating Inputs accepted by discriminatedUnion.
DiscriminatedUnionMemberErrorAn error returned by the member selected by discriminatedUnion.
ExtractTypedExtracts members of a Typed Output union by their type literal.
TypedTypeThe ObjectType returned by typed.
discriminatedUnionDiscriminated Union Type.
typedTagged ObjectType.

Results

NameDescription
UnknownNextResultA nextResult Type with unknown value, error, and done components.
UnknownResultA result Type for Result<unknown, unknown>.
UnknownNextResultA nextResult Type with unknown value, error, and done components.
UnknownResultA result Type for Result<unknown, unknown>.
nextResultCreates a Type for a producer's value, error, or done Result.
resultCreates a Type for Result values.

Recursive Types

NameDescription
LazyTypeA deferred Type with an explicit recursive type declaration.
lazyLazy Type for recursive definitions.

JSON

NameDescription
JsonErrorAn error returned when a string does not contain valid JSON text.
JsonObjectAn exact JSON object containing only JsonValue properties.
JsonObjectInputA candidate JSON object before exact runtime validation.
JsonObjectTypeThe exact top-level JSON object Type.
JsonValueErrorAn error containing one or more issues found in a JsonValue.
JsonValueTypeThe exact root Type of in-memory JSON data values.
JsonA String Brand proving that its exact text parses to JsonValue.
JsonArrayAn exact JSON array containing only JsonValue elements.
JsonArrayInputA candidate JSON array before exact runtime validation.
JsonValueAn exact in-memory JSON data value.
JsonValueInputA candidate JSON value before exact runtime validation.
JsonValueIssueOne issue found while validating an exact JsonValue.
JsonA String Brand proving that its exact text parses to JsonValue.
JsonArrayExact top-level JSON array Type.
JsonObjectExact top-level JSON object Type.
JsonValueExact root Type for JsonValue data trees.
JsonValueFromJsonJson to JsonValue transformation.
jsonCreates a branded Json Type and total conversions for another Type.
jsonToJsonValueTotally parses proven Json text into an exact JsonValue.
jsonValueToJsonTotally encodes an exact JsonValue as canonical Json text.

Localization

VariableDescription
localizeTypesCreates localized copies of selected Types for every locale.

Type utilities

Type AliasDescription
InferErrorsThe union of errors a Type can return from fromUnknown.
InferTypeExtracts the Output of a Type.
ValidateBrandFactoryNumberNumeric parameter preserving literal types in a BrandFactory.