{"id":14957154,"url":"https://github.com/chrislaughlin/prop-type-utils","last_synced_at":"2025-09-09T08:46:28.611Z","repository":{"id":57331768,"uuid":"124137262","full_name":"chrislaughlin/prop-type-utils","owner":"chrislaughlin","description":"A collection of utility functions for react prop types","archived":false,"fork":false,"pushed_at":"2019-11-21T12:24:06.000Z","size":328,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-06T21:11:56.777Z","etag":null,"topics":["javascript","proptypes","reactjs","validation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/chrislaughlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-06T20:54:32.000Z","updated_at":"2019-12-28T17:18:03.000Z","dependencies_parsed_at":"2022-09-05T10:10:42.885Z","dependency_job_id":null,"html_url":"https://github.com/chrislaughlin/prop-type-utils","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrislaughlin%2Fprop-type-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrislaughlin%2Fprop-type-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrislaughlin%2Fprop-type-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrislaughlin%2Fprop-type-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrislaughlin","download_url":"https://codeload.github.com/chrislaughlin/prop-type-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237954673,"owners_count":19393261,"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":["javascript","proptypes","reactjs","validation"],"created_at":"2024-09-24T13:14:15.341Z","updated_at":"2025-02-09T13:30:48.539Z","avatar_url":"https://github.com/chrislaughlin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prop Type Utils\n\n[![npm package][npm-badge]][npm]\n\nProp Typ Utils is a collection of _useful_ prop type validation rules.\n\n\u003cimg src=\"https://raw.githubusercontent.com/chrislaughlin/prop-type-utils/master/public/proptypeutils.png\" alt=\"PropType Utils Logo\" height=\"250px\"/\u003e\n\nLogo designed by [Liffy Designs](http://www.liffydesigns.co.uk/)\n\nInstall\n\n```\nnpm i prop-type-utils\n```\n\nUse\n\nYou can import the named utils from the main package:\n```javascript\nimport { includes, isGreaterThan } from 'prop-type-utils';\n\n......\n\nstatic propTypes = {\n    age: isGreaterThan(18),\n    title: includes('cool')\n}\n```\n\nOr you can import the individual utils as you need them\n\n```javascript\nimport isBetween from 'prop-type-utils/lib/isBetween';\n\n......\n\nstatic propTypes = {\n    score: isBetween(10, 60)\n}\n```\n\n## Utils:\n- [isEven](#iseven)\n- [isGreaterThan](#isgreaterthan)\n- [isLessThan](#islessthan)\n- [isBetween](#isbetween)\n- [includes](#includes)\n- [isRequiredWhen](#isrequiredwhen)\n- [isRequiredWhenAll](#isrequiredwhenAll)\n- [isOnlyOneAllowed](#isOnlyOneAllowed)\n- Have more? Raise a PR\n\n### isEven\n\n```javascript\nimport isEven from 'prop-type-utils/isEven';\n\nFoo.propTypes = {\n    bar: isEven\n}\n\n//Examples\n\u003cFoo bar={1} /\u003e\n//Error\n\n\u003cFoo bar={2} /\u003e\n//Success\n```\n\n### isGreaterThan\n\n```javascript\nimport isGreaterThan from 'prop-type-utils/isGreaterThan';\n\nFoo.propTypes = {\n    bar: isGreaterThan(5)\n}\n\n//Examples\n\u003cFoo bar={1} /\u003e\n//Error\n\n\u003cFoo bar={6} /\u003e\n//Success\n```\n\n### isLessThan\n\n```javascript\nimport isLessThan from 'prop-type-utils/isLessThan';\n\nFoo.propTypes = {\n    bar: isLessThan(5)\n}\n\n//Examples\n\u003cFoo bar={6} /\u003e\n//Error\n\n\u003cFoo bar={1} /\u003e\n//Success\n```\n\n### isBetween\n\n```javascript\nimport isBetween from 'prop-type-utils/isBetween';\n\nFoo.propTypes = {\n    bar: isBetween(5, 10)\n}\n\n//Examples\n\u003cFoo bar={1} /\u003e\n//Error\n\n\u003cFoo bar={6} /\u003e\n//Success\n```\n\n### includes\n\n```javascript\nimport includes from 'prop-type-utils/includes';\n\nFoo.propTypes = {\n    bar: includes('react')\n}\n\n//Examples\n\u003cFoo bar=\"facebook\" /\u003e\n//Error\n\n\u003cFoo bar=\"react-dom\" /\u003e\n//Success\n```\n\n### isRequiredWhen\n\n```javascript\nimport includes from 'prop-type-utils/isRequiredWhen';\n\nFoo.propTypes = {\n    isShowing: PropTypes.bool\n    bar: isRequiredWhen('isShowing')\n}\n\n//Examples\n\u003cFoo isShowing={true} bar={null} /\u003e\n//Error\n\n\u003cFoo isShowing={false} bar={null} /\u003e\n//Success\n\n```\n\n### isRequiredWhenAll\n\n```javascript\nimport isRequiredWhenAll from 'prop-type-utils/isRequiredWhenAll';\n\nFoo.propTypes = {\n    isShowing: PropTypes.bool,\n    foo: PropTypes.string,\n    bar: isRequiredWhenAll(['isShowing', 'foo'])\n}\n\n//Examples\n\u003cFoo isShowing={true} foo={true} bar={null} /\u003e\n//Error\n\n\u003cFoo isShowing={true} foo={false} bar={null} /\u003e\n//Error\n\n\u003cFoo isShowing={false} bar={null} /\u003e\n//Success\n\n\u003cFoo isShowing={true} foo={true} bar={true} /\u003e\n//Success\n\n```\n\n### isOnlyOneAllowed\n\n```javascript\nimport isOnlyOneAllowed from 'prop-type-utils/isOnlyOneAllowed';\n\nFoo.propTypes = {\n    isShowing: isOnlyOneAllowed(['isShowing','foo', 'bar']),\n    foo: isOnlyOneAllowed(['isShowing','foo', 'bar']),\n    bar: isOnlyOneAllowed(['isShowing','foo', 'bar'])\n}\n\n//Examples\n\u003cFoo isShowing={true} foo={true} bar={null} /\u003e\n//Error\n\n\u003cFoo isShowing={true} foo={true} bar={true} /\u003e\n//Error\n\n\u003cFoo isShowing={false} bar={null} /\u003e\n//Success\n\n\u003cFoo isShowing={true} foo={null} bar={null} /\u003e\n//Success\n\n```\n\n[build-badge]: https://img.shields.io/travis/user/repo/master.png?style=flat-square\n[build]: https://travis-ci.org/user/repo\n\n[npm-badge]: https://img.shields.io/npm/v/npm-package.png?style=flat-square\n[npm]: https://www.npmjs.org/package/npm-package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrislaughlin%2Fprop-type-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrislaughlin%2Fprop-type-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrislaughlin%2Fprop-type-utils/lists"}