{"id":26569010,"url":"https://github.com/velocityzen/io-ts-parser-types","last_synced_at":"2026-02-19T08:36:36.011Z","repository":{"id":66186950,"uuid":"581323035","full_name":"velocityzen/io-ts-parser-types","owner":"velocityzen","description":"io-ts types for making parsers","archived":false,"fork":false,"pushed_at":"2025-04-24T20:10:36.000Z","size":2531,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T08:46:29.137Z","etag":null,"topics":["fp-ts","io-ts","parser","runtime","types","typescript","validation"],"latest_commit_sha":null,"homepage":"","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/velocityzen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-22T21:40:00.000Z","updated_at":"2025-04-24T20:10:40.000Z","dependencies_parsed_at":"2023-12-12T16:47:30.691Z","dependency_job_id":"f0806ba8-7e51-4890-9708-4c34428e3d83","html_url":"https://github.com/velocityzen/io-ts-parser-types","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/velocityzen/io-ts-parser-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velocityzen%2Fio-ts-parser-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velocityzen%2Fio-ts-parser-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velocityzen%2Fio-ts-parser-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velocityzen%2Fio-ts-parser-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/velocityzen","download_url":"https://codeload.github.com/velocityzen/io-ts-parser-types/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velocityzen%2Fio-ts-parser-types/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29608589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["fp-ts","io-ts","parser","runtime","types","typescript","validation"],"created_at":"2025-03-22T20:19:17.162Z","updated_at":"2026-02-19T08:36:36.006Z","avatar_url":"https://github.com/velocityzen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# io-ts-parser-types\n\n[![NPM Version](https://img.shields.io/npm/v/io-ts-parser-types.svg?style=flat-square)](https://www.npmjs.com/package/io-ts-parser-types)\n[![NPM Downloads](https://img.shields.io/npm/dt/io-ts-parser-types.svg?style=flat-square)](https://www.npmjs.com/package/io-ts-parser-types)\n\nio-ts codec types for parsing data\n\n# Install\n\n`npm i io-ts-parser-types`\n\n**Note**. [`fp-ts`](https://github.com/gcanti/fp-ts) and [`io-ts`](https://github.com/gcanti/io-ts) are peer dependencies for `io-ts-parser-types`\n\n# Usage\n\n## typeFromRegexp(regexp, codec)\n\nreturns a codec that matches string with regexp and the validates all named capture groups with codec.\n\n### Example\n\n```ts\nconst dataCodec = t.type({\n  prop: NumberFromString,\n  value: BooleanFromString,\n});\n\nconst codec = typeFromRegexp(/p(?\u003cprop\u003e\\d+)\\/v(?\u003cvalue\u003e.+)/, dataCodec);\nexpect(decode(codec, \"p123/vtrue\")).toEqual({\n  prop: 123,\n  value: true,\n});\n```\n\n---\n\nBoth following codecs accept the same parameters `schema` and `name`. The `name` is just a codec name. for Schema look for example\n\n## typeFromString(schema, name)\n\nreturns a codec that extracts fields for the position in the string and returns an object. **encode returns the object with encoded fields**\n\n## codecTypeFromString(schema, name)\n\nreturns a codec that extracts fields for the position in the string and returns an object. **encode returns the string with field values in respective positions**\n\n### Example\n\n```ts\nconst schema = {\n  prop1: {\n    position: [1, 2],\n    codec: NumberFromString,\n  },\n  prop2: {\n    position: [5, 9],\n    codec: BooleanFromString,\n  },\n};\nconst typeC = typeFromString(schema, \"string to object\");\nconst codecTypeC = codecTypeFromString(schema, \"string to object to string\");\n\nconst result = {\n  prop1: 2,\n  prop2: true,\n};\n\nexpect(decode(typeC, \"12345true78\")).toEqual(result);\nexpect(decode(codecTypeC, \"12345true78\")).toEqual(result);\n\nexpect(typeC.encode(result)).toEqual({\n  prop1: \"2\",\n  prop2: \"true\",\n});\nexpect(codecTypeC.encode(result)).toEqual(\" 2   true\");\n```\n\n---\n\n## typeFromSeparatedValues(separator, schema, name)\n\n- separator: string | RegExp\n\nreturns a codec that extracts fields for the the string with values separated by `separator` and returns an object. **encode returns the object with encoded fields**\n\n## codecTypeFromSeparatedValues(separator, schema, name)\n\n- separator: string\n\nreturns a codec that extracts fields for the the string with values separated by `separator` and returns an object. **encode returns the string with field values in respective positions**\n\n### Example\n\n```ts\nconst schema = {\n  prop1: {\n    position: 1,\n    codec: NumberFromString,\n  },\n  prop2: {\n    position: 0,\n    codec: BooleanFromString,\n  },\n};\nconst typeC = typeFromSeparatedValues(\"|\", schema, \"string to object\");\nconst codecTypeC = codecTypeFromSeparatedValues(\"|\", schema, \"string to object to string\");\n\nconst result = {\n  prop1: 2,\n  prop2: true,\n};\n\nexpect(decode(typeC, \"true|2\")).toEqual(result);\nexpect(decode(codecTypeC, \"true|2\")).toEqual(result);\n\nexpect(typeC.encode(result)).toEqual({\n  prop1: \"2\",\n  prop2: \"true\",\n});\nexpect(codecTypeC.encode(result)).toEqual(\"true|2\");\n```\n\n---\n\n## Number\n\n- **integerFrom(options)** - generic codec creation function for integer values\n- **decimalFrom(options)** - generic codec creation function for decimal values. It uses [decimal.js](http://mikemcl.github.io/decimal.js)\n- **floatFrom(options)** - generic codec creation function for float values\n  - regexp - optional, RegExp, matches string and returns **first** group as a number, ignores commas as a thousand separator\n  - name - optional, name of the codec\n- **ZeroFromNull** - returns `0` for `null`\n- **DecimalFromPercentString** - returns a percent value from string like e.g., 58% -\u003e 0.58\n\n## Boolean\n\n- **booleanFrom(options)** - generic boolean codec creator function.\n  - **caseSensitive** - default: true,\n  - **true** - true value, **false** - false value\n  - **true** - true value, strict - optional, boolean, if set to true only true value matches\n  - **false** - false value, strict - optional, boolean, if set to true only false value matches\n\n## Null\n\n- **nullFrom(options)** - generic null codec creator function\n  - **match** - array of values to be valid as `null`\n  - caseSensitive - optional, default true, matches values from `match` exactly. If you want to treat strings from the `match` array as non case-sensitive set them to `false`\n\n## String\n\n- **TrimmedString** - validates that value is a string and trims white space.\n\nLicense\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvelocityzen%2Fio-ts-parser-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvelocityzen%2Fio-ts-parser-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvelocityzen%2Fio-ts-parser-types/lists"}