Skip to content

Latest commit

 

History

History
78 lines (66 loc) · 5.8 KB

paratype.md

File metadata and controls

78 lines (66 loc) · 5.8 KB

Home > paratype

paratype package

Basic type validation and serialization

Functions

Function Description
arrayType(itemType) Constructs a Type that represents an array of the specified item type.
classType(ctor) Matches instances of a specific class
constType(fixed) Constructs a Type that represents a fixed string value.
customClassType(ctor, fromJsonValue, toJsonValue) Matches instances of a specific class and uses custom conversion callbacks
discriminatorType(key, union) Constructs a Type that represents a union of other types, each with a common distriminator property.
enumType(values) Constructs a Type that represents an enumeration of the specified values.
formatPath(path) Returns a string that represents the specified value path
isType(value) Determines whether the specified value is a Type
lazyType(init) Constructs a late bound Type.
mapType(valueType) Constructs a Type that represents a map with string keys and uniform values
RecordClass(propsType) Returns a RecordConstructor for the specified record type
RecordClass(propsType, base) Returns a RecordConstructor for the specified record type
RecordClass(propsType, base, dataType, propsToData) Returns a RecordConstructor for the specified record type
recordClassType(lazy) Creates a run-time type for a record class
recordType(properties) Constructs a Type that represents a record with the specified properties
tupleType(itemTypes) Constructs a Type that represents a tuple with the specified item types.
unionType(types) Constructs a Type that represents a union of other types.

Interfaces

Interface Description
Equatable Implements equality
FromData The static data conversion interface that must be implemented by record classes with implic data conversion
JsonObject An object where keys are strings and values are JSON values
RecordObject Methods implemented by RecordConstructor instances
RecordOptions Specifies behavior for a record type
RecordType A run-time record type
Type A run-time type
TypeClass The static interface of type classes
TypeInstance The interface of type class instances

Variables

Variable Description
anyType Matches any value
binaryType Matches ArrayBuffer values
booleanType Matches boolean values
integerType Matches safe integer values
jsonValueType Matches JSON values
nonNegativeIntegerType Matches safe integer values that are greater than or equal to zero
nullType Represents a type that only matches null values
numberType Matches number values
positiveIntegerType Matches safe integer values that are greater than zero
stringType Matches string values
timestampType Matches timestamp values
voidType Represents a type that only matches undefined values

Type Aliases

Type Alias Description
Constructor A constructor function
ErrorCallback_2 A callback that, given a message, creates an error
JsonArray An array of JSON values
JsonPrimitive One of the JSON primitive types
JsonValue A JSON value
MaybeFromData Optional or required data conversion
OptionalPropsOf Extracts optional properties from a type
PathArray An array of string and/or numbers that represents the path of a value
Predicate Returns true if the specified value matches a predicate
PropertyTypes Maps properties to their corresponding run-time types
RecordConstructor A constructor for record classes
TypeOf Extracts the underlying type from a Type (it gets the T from Type<T>)