{"id":15295947,"url":"https://github.com/alixander/redux-store-validator","last_synced_at":"2025-10-07T08:30:43.925Z","repository":{"id":65373147,"uuid":"81676099","full_name":"alixander/redux-store-validator","owner":"alixander","description":"Add validation to your Redux reducers","archived":true,"fork":false,"pushed_at":"2017-02-19T02:18:32.000Z","size":9,"stargazers_count":26,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-10T21:04:59.667Z","etag":null,"topics":["javascript","react","redux"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/alixander.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}},"created_at":"2017-02-11T19:19:52.000Z","updated_at":"2023-01-10T18:23:53.000Z","dependencies_parsed_at":"2023-01-20T02:18:06.926Z","dependency_job_id":null,"html_url":"https://github.com/alixander/redux-store-validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alixander/redux-store-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixander%2Fredux-store-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixander%2Fredux-store-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixander%2Fredux-store-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixander%2Fredux-store-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alixander","download_url":"https://codeload.github.com/alixander/redux-store-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixander%2Fredux-store-validator/sbom","scorecard":{"id":184660,"data":{"date":"2025-08-11","repo":{"name":"github.com/alixander/redux-store-validator","commit":"6a4a81d1ea1ba3bec9bda62d3071afb58f3a32ce"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T19:34:30.477Z","repository_id":65373147,"created_at":"2025-08-16T19:34:30.477Z","updated_at":"2025-08-16T19:34:30.477Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278323262,"owners_count":25968104,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["javascript","react","redux"],"created_at":"2024-09-30T18:08:43.816Z","updated_at":"2025-10-07T08:30:43.348Z","avatar_url":"https://github.com/alixander.png","language":"JavaScript","funding_links":[],"categories":["Marks"],"sub_categories":["[React - A JavaScript library for building user interfaces](http://facebook.github.io/react)"],"readme":"Redux Store Validator\n=========\n![travis-badge](https://travis-ci.org/alixander/redux-store-validator.svg?branch=master)\n\nWrapper to add validation to your Redux reducers\n\n```\nnpm install --save redux-store-validator\n```\n\n### Purpose\n\nIn a large React/Redux app, the store can become intractable. A common cause of bugs is when the data in the store has changed in a way that the developer didn't expect. `redux-store-validator` is intended to facilitate adding detection of when such a scenario occurs. You can add as many or as little validators to specific parts of your store, and act on it accordingly. For example, you can add a validator to check that a value which you expected to be always positive ever becomes negative. If so, you can log or recover right after the offending action modifies the store.\n\n### Usage\n\nWrap your reducers\n\n#### reducers/index.js\n\n```js\nimport { withValidation } from 'redux-store-validator';\n\nimport aReducer, { validator as aValidator } from './a';\nimport { bReducer } from './b';\n\nconst reducers = {\n  a: aReducer,\n  b: bReducer\n}\n\nconst validators = {\n  // Only add validators for substates you want validation on\n  a: aValidator\n}\n\n// Instead of\n// const rootReducer = combineReducers(reducers);\n// You wrap your reducers in 'withValidation' and pass in the validators to execute\nconst rootReducer = combineReducers(withValidation(reducers, validators));\n```\n\nAdd validators to reducers as needed\n\n#### reducers/a.js\n```js\nexport function validator(state) {\n  return state.word === 'asdf';\n}\n\nexport default function(state, action) {\n  switch(action.type) {\n    case 'asdf':\n      state.word = 'asdf';\n      return state;\n    default:\n      return state;\n  }\n}\n```\n\nThat's it. After you've wrapped your reducers and added validators, you can detect if the store has become invalid by querying the state.\n\n`redux-store-validator` adds the following to your redux state:\n\n`state[INVALID_KEYS]`: Array of keys which correspond to the substates that are invalid.\n\nYou can act upon it however you like. Below are just a few examples\n\n## Examples of acting upon invalid store\n\nIn your component you can choose not to render with the new data if it's invalid.\n\n### components/myComponent.jsx\n\n```js\nimport { INVALID_KEYS } from 'redux-store-validator';\n...\n\nconst myComponent = React.createClass({\n  props: {\n    text: PropTypes.string,\n    isValid: PropTypes.bool\n  },\n\n  shouldComponentUpdate(nextProps) {\n    return nextProps.isValid;\n  },\n\n  ...\n  \n  render() {\n    return \u003cdiv\u003e{this.props.text}\u003c/div\u003e;\n  }\n});\n\nfunction mapStateToProps(state) {\n  return {\n    text: state.a.word,\n    isValid: state[INVALID_KEYS].includes('a')\n  }\n}\n...\n```\n\n---------------------------\n\nYou can replace the state with a default valid one as soon as an action caused it to become invalid.\n\n#### Back in reducers/index.js\n\n```js\nimport aReducer, {\n  validator as aValidator,\n  defaultState as aDefaultState\n} from './a';\nimport { bReducer } from './b';\n\nimport { INVALID_KEYS } from 'redux-store-validator';\n\nconst reducers = {\n  a: aReducer,\n  b: bReducer\n}\n\nconst validators = {\n  // Only add validators for substates you want validation on\n  a: aValidator\n}\n\nconst defaultStates = {\n  a: aDefaultState\n}\n\nconst rootReducer = combineReducers(withValidation(reducers, validators));\n\nfunction replaceInvalid(combinedReducer) {\n  return (state, action) =\u003e {\n    const newState = combinedReducer(state, action);\n    if (newState.INVALID_KEYS.length === 0) {\n      return newState;\n    }\n    for (const validatedSubstate of Object.keys(validators)) {\n      if (newState[INVALID_KEYS].includes(validatedSubstate)) {\n        newState[validatedSubstate] = defaultStates[validatedSubstate]\n        // If the default state is valid, the INVALID_KEYS will remove the state key in the next reduction step\n      }\n    }\n    return newState;\n  }\n}\nexport default replaceInvalid(rootReducer);\n```\n\n---------------------------\n\nYou can log in a logger middleware\n\n#### middlewares/Logger.js\n\n```js\nimport { INVALID_KEYS } from 'redux-store-validator';\n\nexport default ({getState}) =\u003e (next) =\u003e (action) =\u003e {\n  const state = getState(); \n  if (state[INVALID_KEYS].length !== 0) {\n    // Log the invalid states\n    for (const key of state[INVALID_KEYS]) {\n      const substate = state[key];\n      ...\n    }\n    ...\n  }\n  ...\n  return next(action);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falixander%2Fredux-store-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falixander%2Fredux-store-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falixander%2Fredux-store-validator/lists"}