{"id":16227046,"url":"https://github.com/matanyadaev/peach","last_synced_at":"2025-04-08T04:24:46.432Z","repository":{"id":245347277,"uuid":"817355238","full_name":"MatanYadaev/peach","owner":"MatanYadaev","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-12T15:49:39.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T15:13:47.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatanYadaev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-19T14:27:26.000Z","updated_at":"2024-06-26T22:16:06.000Z","dependencies_parsed_at":"2024-06-27T00:58:48.765Z","dependency_job_id":"716dba37-fc67-44d6-9dfc-3609634721a6","html_url":"https://github.com/MatanYadaev/peach","commit_stats":null,"previous_names":["matanyadaev/peach"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatanYadaev%2Fpeach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatanYadaev%2Fpeach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatanYadaev%2Fpeach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatanYadaev%2Fpeach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatanYadaev","download_url":"https://codeload.github.com/MatanYadaev/peach/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247775156,"owners_count":20993891,"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":[],"created_at":"2024-10-10T12:51:31.180Z","updated_at":"2025-04-08T04:24:46.410Z","avatar_url":"https://github.com/MatanYadaev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Peach\n\nAnother validation library for TypeScript.\n\n## Features\n\n- Type-safe validation\n- Extensible\n- Serializable\n- Compiles into JSON Schema\n- Internationalization\n\n## Usage\n\n```ts\nimport { schemas, createValidator } from 'peach';\n\nconst isBase64String = (value: string) =\u003e\n  Buffer.from(value, 'base64').toString('utf8') === value;\n\nconst p = createValidator({\n  schemas: {\n    // Pick built-in schemas:\n    ...schemas,\n    // Or define your own:\n    base64: {\n      check: isBase64String,\n      toJsonSchema: (jsonSchema) =\u003e ({\n        ...jsonSchema,\n        contentEncoding: 'base64',\n      }),\n    }, \n  },\n});\n\nconst FileSchema = p.object({\n  name: p.pipe(p.string('Name is required'), p.trim(), p.minLength(1, 'Name must be at least 1 character long')),\n  content: p.pipe(p.string('Content is required'), p.base64('Content must be a base64 string')),\n});\n\nconsole.log(FileSchema); // Schemas are serializable\n// [{\n//   type: 'object',\n//   properties: {\n//     name: [\n//       { type: 'string', message: 'Name is required' },\n//       { type: 'trim' },\n//       { type: 'minLength', min: 1, message: 'Name must be at least 1 character long' },\n//     ],\n//     content: [\n//       { type: 'string', message: 'Content is required' },\n//       { type: 'base64', message: 'Content must be a base64 object' },\n//     ],\n//   },\n// }]\n\nconst file = p.parse(FileSchema, {\n  name: 'test.txt',\n  content: 'dGVzdA==',\n  extra: 'extra', // This will be ignored\n});\n\n// `file` is now typed as `{ name: string; content: string }`\n\nconsole.log(file);\n// {\n//   name: 'test.txt',\n//   content: 'dGVzdA==',\n// }\n\n// Schemas can be converted to JSON Schema\nconsole.log(p.toJsonSchema(FileSchema));\n// {\n//   type: 'object',\n//   properties: {\n//     name: { type: 'string' },\n//     content: { type: 'string', contentEncoding: 'base64' },\n//   },\n//   required: ['name', 'content'],\n//   additionalProperties: false,\n// }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatanyadaev%2Fpeach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatanyadaev%2Fpeach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatanyadaev%2Fpeach/lists"}