{"id":15058817,"url":"https://github.com/yuforium/activity-streams","last_synced_at":"2026-03-03T13:37:56.154Z","repository":{"id":40449957,"uuid":"305431305","full_name":"yuforium/activity-streams","owner":"yuforium","description":"Activity Streams validation for Typescript","archived":false,"fork":false,"pushed_at":"2024-07-05T20:23:10.000Z","size":861,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-13T00:23:48.002Z","etag":null,"topics":["activitypub","activitystreams","activitystreams-vocabulary"],"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/yuforium.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":"2020-10-19T15:34:10.000Z","updated_at":"2023-12-29T17:57:01.000Z","dependencies_parsed_at":"2024-03-04T14:08:52.847Z","dependency_job_id":"88758b3c-11f9-47e2-a5d0-08d90918ab00","html_url":"https://github.com/yuforium/activity-streams","commit_stats":{"total_commits":30,"total_committers":3,"mean_commits":10.0,"dds":0.3666666666666667,"last_synced_commit":"1ae374d1e7fc8d29507ce9271b1a8e2667410f48"},"previous_names":["yuforium/activity-streams-validator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yuforium/activity-streams","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuforium%2Factivity-streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuforium%2Factivity-streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuforium%2Factivity-streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuforium%2Factivity-streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuforium","download_url":"https://codeload.github.com/yuforium/activity-streams/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuforium%2Factivity-streams/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29452584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["activitypub","activitystreams","activitystreams-vocabulary"],"created_at":"2024-09-24T22:31:01.328Z","updated_at":"2026-03-03T13:37:56.126Z","avatar_url":"https://github.com/yuforium.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @yuforium/activity-streams\n_Activity Streams Validator and Transformer_\n\n## Getting Started\n```sh\nnpm i --save \\\n  @yuforium/activity-streams \\\n  class-validator class-transformer \\\n  reflect-metadata\n```\n\n## Using Built-In Classes\nUse built in classes to do validation using class-validator:\n\n```typescript\nimport 'reflect-metadata';\nimport { Note } from '@yuforium/activity-streams';\nimport { validate } from 'class-validator';\n\nconst note = new Note();\n\nasync function validateNote() {\n  let errors = await validate(note);\n\n  if (errors.length \u003e 0) {\n    console.log('the note is invalid');\n  }\n  else {\n    console.log('the note is valid');\n  }\n}\n\nnote.id = 'https://yuforium.com/users/chris/note-123';\n\nvalidateNote(); // the note is valid\n\nnote.id = 'invalid, id must be a valid URL';\n\nvalidateNote(); // the note is invalid\n```\n\n## Defining Custom Validation Rules\nYou can define your own validation rules by extending the built in classes or initializing your own using one of several methods using a base type (such as a link, object, activity, or collection):\n\n```typescript\nimport { Expose } from 'class-transformer';\nimport { IsString, validate } from 'class-validator';\nimport { ActivityStreams } from '@yuforium/activity-streams';\nimport 'reflect-metadata';\n\n\n// Creates a CustomNote type class as an Activity Streams Object\nclass CustomNote extends ActivityStreams.object('CustomNote') {\n  @Expose()\n  @IsString({each: true})\n  public customField: string | string[];\n};\n\n// Add this to the built-in transformer\nActivityStreams.transformer.add(CustomNote);\n\n// new instance of CustomNote\nconst custom: CustomNote = ActivityStreams.transform({\n  type: 'CustomNote',\n  customField: 5 // invalid, must be a string\n});\n\n// will get error \"each value in customField must be a string\"\nvalidate(custom).then(errors =\u003e {\n  errors.forEach(error =\u003e { console.log(error) });\n});\n```\n\n## Composite Transformation\nIn addition to supporting custom classes, multiple types may be defined and interpolated from the `transform()` method.\n\n```typescript\nimport { Expose } from 'class-transformer';\nimport { IsString, validate } from 'class-validator';\nimport { ActivityStreams } from '@yuforium/activity-streams';\nimport 'reflect-metadata';\n\n\n// Creates CustomNote class as an Activity Streams Object\nclass CustomNote extends ActivityStreams.object('CustomNote') {\n  @Expose()\n  @IsString({each: true})\n  public customField: string | string[];\n};\n\n// Add this to the built in transformer\nActivityStreams.transformer.add(CustomNote);\n\n// new instance of CustomNote\nconst custom = ActivityStreams.transform({\n  type: 'CustomNote',\n  customField: 5 // invalid, must be a string\n});\n\n// will get error \"each value in customField must be a string\"\nvalidate(custom).then(errors =\u003e {\n  errors.forEach(error =\u003e { console.log(error) });\n});\n```\n\n## Requiring Optional Fields\nMany fields in the Activity Streams specification are optional, but you may want to make them required your own validation purposes.\n\nExtend the classes you need and then use the `@IsRequired()` decorator for these fields.\n\n_my-note.ts_\n```typescript\nimport { Note, IsRequired } from '@yuforium/activity-streams';\n\nexport class MyNote extends Note {\n  // content field is now required\n  @IsRequired()\n  public content;\n}\n```\n_validate.ts_\n```typescript\nimport { MyNote } from './my-note';\n\nconst note = new MyNote();\n\nvalidate(note); // fails\n\nnote.content = \"If you can dodge a wrench, you can dodge a ball.\";\n\nvalidate(note); // works\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuforium%2Factivity-streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuforium%2Factivity-streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuforium%2Factivity-streams/lists"}