{"id":26642699,"url":"https://github.com/teguru-labs/strapi-plugin-required-relation-field","last_synced_at":"2025-04-10T22:39:20.336Z","repository":{"id":279014198,"uuid":"937480552","full_name":"teguru-labs/strapi-plugin-required-relation-field","owner":"teguru-labs","description":"Enforces required relation fields in strapi to be non-empty on save or publish","archived":false,"fork":false,"pushed_at":"2025-04-04T19:42:23.000Z","size":15889,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T20:32:17.133Z","etag":null,"topics":["relation-validator","strapi-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/strapi-plugin-required-relation-field","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teguru-labs.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},"funding":{"custom":["paypal.me/kimyvgy","me.momo.vn/kimyvgy"]}},"created_at":"2025-02-23T06:37:48.000Z","updated_at":"2025-03-08T03:39:22.000Z","dependencies_parsed_at":"2025-03-28T05:28:34.389Z","dependency_job_id":null,"html_url":"https://github.com/teguru-labs/strapi-plugin-required-relation-field","commit_stats":null,"previous_names":["teguru-labs/strapi-plugin-required-relation-field"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguru-labs%2Fstrapi-plugin-required-relation-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguru-labs%2Fstrapi-plugin-required-relation-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguru-labs%2Fstrapi-plugin-required-relation-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguru-labs%2Fstrapi-plugin-required-relation-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teguru-labs","download_url":"https://codeload.github.com/teguru-labs/strapi-plugin-required-relation-field/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312175,"owners_count":21082637,"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":["relation-validator","strapi-plugin"],"created_at":"2025-03-24T19:27:27.547Z","updated_at":"2025-04-10T22:39:20.314Z","avatar_url":"https://github.com/teguru-labs.png","language":"TypeScript","funding_links":["paypal.me/kimyvgy","me.momo.vn/kimyvgy"],"categories":[],"sub_categories":[],"readme":"# Strapi Plugin: Required Relation Field\n\n[![ci](https://github.com/teguru-labs/strapi-plugin-required-relation-field/actions/workflows/ci.yaml/badge.svg)](https://github.com/teguru-labs/strapi-plugin-required-relation-field/actions/workflows/ci.yaml)\n[![NPM version](https://img.shields.io/npm/v/strapi-plugin-required-relation-field.svg)](https://www.npmjs.com/package/strapi-plugin-required-relation-field)\n\nEnforces required relation fields in Strapi to be non-empty on save or publish.\n\n![Preview](./images/content.gif)\n\n## Requirements\n\n- Strapi v5.x (supported)\n- Strapi v4.x (untested)\n\n## Installation\n\nYou just need to install the `strapi-plugin-required-relation-field` package via `npm` or `yarn` at the root of your Strapi project:\n\n**npm:**\n\n```bash\nnpm i strapi-plugin-required-relation-field\n```\n\n**yarn:**\n\n```bash\nyarn add strapi-plugin-required-relation-field\n```\n\n## Usage\n\nSimply set `required: true` for relations in your schemas, and everything will work out-of-the-box. For example:\n\n```json\n# src/api/story-reaction/content-types/story-reaction/schema.json\n{\n  \"kind\": \"collectionType\",\n  \"collectionName\": \"story_reactions\",\n  \"info\": {\n    \"singularName\": \"story-reaction\",\n    \"pluralName\": \"story-reactions\",\n    \"displayName\": \"Story Reaction\",\n    \"description\": \"\"\n  },\n  \"options\": {\n    \"draftAndPublish\": false\n  },\n  \"attributes\": {\n    \"story\": {\n      \"type\": \"relation\",\n      \"relation\": \"manyToOne\",\n      \"target\": \"api::story.story\",\n      \"inversedBy\": \"storyReactions\",\n      \"required\": true\n    },\n    \"user\": {\n      \"type\": \"relation\",\n      \"relation\": \"manyToOne\",\n      \"target\": \"plugin::users-permissions.user\",\n      \"inversedBy\": \"storyReactions\",\n      \"required\": true\n    },\n    \"reaction\": {\n      \"type\": \"relation\",\n      \"relation\": \"manyToOne\",\n      \"target\": \"api::reaction.reaction\",\n      \"inversedBy\": \"storyReactions\",\n      \"required\": true\n    }\n  }\n}\n```\n\n## Development\n\nTo test the plugin during development, build it with the `watch:link` command:\n\n```bash\nyarn watch:link\n```\n\nNext, link it to a local Strapi project. In a new terminal window, run:\n\n```bash\ncd /path/to/strapi/project\nyarn dlx yalc add --link strapi-plugin-required-relation-field\nyarn install\n```\n\nSince this plugin is installed via `node_modules`, you don't need to explicitly add it to your `plugins` configuration file. Running the `develop` command will automatically detect the plugin.\n\nStart your Strapi project with:\n\n```bash\nyarn develop\n```\n\nYou are now ready to contribute the plugin. Please note that any server changes will require a restart to take effect.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteguru-labs%2Fstrapi-plugin-required-relation-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteguru-labs%2Fstrapi-plugin-required-relation-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteguru-labs%2Fstrapi-plugin-required-relation-field/lists"}