{"id":20178228,"url":"https://github.com/altostra/type-validations","last_synced_at":"2025-04-10T04:33:24.432Z","repository":{"id":37863153,"uuid":"263721211","full_name":"altostra/type-validations","owner":"altostra","description":"Data validations library","archived":false,"fork":false,"pushed_at":"2023-02-05T12:19:57.000Z","size":717,"stargazers_count":41,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T05:44:06.239Z","etag":null,"topics":["library","typescript","validations"],"latest_commit_sha":null,"homepage":"https://medium.com/altostra/better-data-validation-in-typescript-3d6446107740","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/altostra.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-13T19:12:37.000Z","updated_at":"2023-08-03T12:03:43.000Z","dependencies_parsed_at":"2023-02-18T23:31:04.246Z","dependency_job_id":null,"html_url":"https://github.com/altostra/type-validations","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altostra%2Ftype-validations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altostra%2Ftype-validations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altostra%2Ftype-validations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altostra%2Ftype-validations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altostra","download_url":"https://codeload.github.com/altostra/type-validations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248157713,"owners_count":21057057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","typescript","validations"],"created_at":"2024-11-14T02:19:53.079Z","updated_at":"2025-04-10T04:33:24.400Z","avatar_url":"https://github.com/altostra.png","language":"TypeScript","readme":"# Type validations\n\n[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/altostra/type-validations)\n![CI](https://github.com/altostra/type-validations/workflows/CI/badge.svg)\n[![npm version](https://badge.fury.io/js/%40altostra%2Ftype-validations.svg)](https://badge.fury.io/js/%40altostra%2Ftype-validations)\n\nType validations is a library for creating *type-validator*s: augmented \n[*type-guard*](https://www.typescriptlang.org/docs/handbook/2/narrowing.html)s \nthat perform full runtime type-validation and let TypeScript type checker know what a \ntype may be in a certain context.\n\n## Installation\n\n```sh\n$ npm install @altostra/type-validations\n```\n\n## Reference\n\nA full reference can be found [here](./docs/reference/index.md).\n\n### [`allOf`](./docs/reference/docs/reference/allOf.md)\n\nCreates *type-validator*s for an\n[*intersections-type*](https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types)\nfrom a list of *type-validator*s.\n\n### [`anyOf`](./docs/reference/anyOf.md)\n\nCreates *type-validator*s for a\n[*union-type*](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)\nfrom a list of *type-validator*s.\n\n### [`arrayOf`](./docs/reference/arrayOf.md)\n\nGiven *type-guard* for type `T`, creates a *type-validator* for `T[]`.\n\n### [`assertBy`](./docs/reference/assertions.md)\n\nCreate *assertion-functions* from *type-validation* and an error-factory.\n\n### [`enumOf`](./docs/reference/enumOf.md)\n\nCreates a *type-validation* that checks if a value is one of the specified values\n(using strict equality).\n\n### [`is`](./docs/reference/is.md)\n\nCreates a *type-validation* that only allows values that are strictly equal to \nthe provided value.\n\n### [`isEmptyArray`](./docs/reference/isEmptyArray.md)\n\nA *type-validation* that checks if a value is an empty array.\n\n### [`isEmptyObject`](./docs/reference/isEmptyObject.md)\n\nA *type-validation* that checks if a value is an empty object.\n\n### [`isFunction`](./docs/reference/isFunction.md)\n\nCreates a *type-validation* that checks if a value is a function with a specified length.\n\n### [`maybe`](./docs/reference/maybe.md)\n\nCreates a *type-validation* that checks if a value is of validated type, `undefined`, \nand optionally `null`.\n\n### [`objectOf`](./docs/reference/objectOf.md)\n\nCreates *type-validation* that checks if a value is an object that all its properties\nare validated with the provided validations.\n\n### [`recordOf`](./docs/reference/recordOf.md)\n\nCreates *type-validator* that checks that a given value is an object and that\nall its own-enumerable properties are of a specified type.\n\n### [`singleOrArray`](./docs/reference/singleOrArray.md)\n\nCreates a *type-validation* that checks if a value is either a specific type or an\narray of that type.\n\n### [`taggedUnionOf`](./docs/reference/taggedUnionOf.md)\n\nCreates *type-validator*s for a\n[*union-type*](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)\nfrom a mapping between specified tag property values and validators, when the *union-type* \nis in fact a [*discriminated union*](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions).\n\n### [`tupleOf`](./docs/reference/tupleOf.md)\n\nCreates a *type-validation* that checks that an object is an array with a specific length,\nand has all the provided indices validated.\n\n### [Primitives](./docs/reference/primitives.md)\n\n#### *Type-validations*\n- `string`\n- `maybeString`\n- `number`\n- `maybeNumber`\n- `boolean`\n- `maybeBoolean`\n- `nullValidation`\n- `nullOrUndefined`\n- `undefinedValidation`\n- `symbol`\n- `maybeSymbol`\n- `bigint`\n- `maybeBigint`\n- `any`\n- `unknown`\n- `never`\n\n#### *Type-assertions*\n\n- `stringAssertion`\n- `maybeStringAssertion`\n- `numberAssertion`\n- `maybeNumberAssertion`\n- `booleanAssertion`\n- `maybeBooleanAssertion`\n- `nullAssertion`\n- `nullOrUndefinedAssertion`\n- `undefinedAssertion`\n- `symbolAssertion`\n- `maybeSymbolAssertion`\n- `bigintAssertion`\n- `maybeBigintAssertion`\n- `anyAssertion`\n- `unknownAssertion`\n- `assert`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltostra%2Ftype-validations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltostra%2Ftype-validations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltostra%2Ftype-validations/lists"}