Type validations is a library for creating type-validators: augmented type-guards that perform full runtime type-validation and let TypeScript type checker know what a type may be in a certain context.
$ npm install @altostra/type-validations
A full reference can be found here.
Creates type-validators for an intersections-type from a list of type-validators.
Creates type-validators for a union-type from a list of type-validators.
Given type-guard for type
T, creates a type-validator for
Create assertion-functions from type-validation and an error-factory.
Creates a type-validation that checks if a value is one of the specified values (using strict equality).
Creates a type-validation that only allows values that are strictly equal to the provided value.
A type-validation that checks if a value is an empty array.
A type-validation that checks if a value is an empty object.
Creates a type-validation that checks if a value is a function with a specified length.
Creates a type-validation that checks if a value is of validated type,
Creates type-validation that checks if a value is an object that all its properties are validated with the provided validations.
Creates type-validator that checks that a given value is an object and that all its own-enumerable properties are of a specified type.
Creates a type-validation that checks if a value is either a specific type or an array of that type.
Creates a type-validation that checks that an object is an array with a specific length, and has all the provided indices validated.