Registry / testing / redux-orm-proptypes

redux-orm-proptypes

JSON →
library0.1.0jsnpmunverified

A small utility, v0.1.0 (single release, no active development), that provides a mixin for Redux-ORM Model to validate props using React PropTypes and apply defaultProps. It wraps the Model.create and model.update methods to enforce prop types and merge defaults. Differentiators: lightweight, enforces prop validation in redux-orm models, integrates with React's PropTypes and defaultProps. No further releases expected.

npm install redux-orm-proptypes
INSTALL
IMPORT
SIG · REDUX-ORM-PROPTYPE
R
redux-orm-proptypes
testingjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

propTypesMixin
import propTypesMixin from 'redux-orm-proptypes'
import { propTypesMixin } from 'redux-orm-proptypes'
Default export, not named. Use default import.
getPropTypesMixin
import { getPropTypesMixin } from 'redux-orm-proptypes'
const getPropTypesMixin = require('redux-orm-proptypes').default
Named export for factory function. CommonJS require is possible but avoid .default.
default
const propTypesMixin = require('redux-orm-proptypes').default
const propTypesMixin = require('redux-orm-proptypes')
CommonJS users must use .default because the package uses ES modules.

Shows how to use the mixin to add PropTypes validation and defaultProps to a redux-orm Model.

import PropTypes from 'prop-types'; import { Model } from 'redux-orm'; import propTypesMixin from 'redux-orm-proptypes'; const ValidatingModel = propTypesMixin(Model); class Person extends ValidatingModel {} Person.modelName = 'Person'; Person.propTypes = { name: PropTypes.string.isRequired, age: PropTypes.number.isRequired, }; Person.defaultProps = { age: 0, }; // Inside a session: Person.create({ name: 'Alice', age: 30 }); console.log(Person.create({ name: 'Bob' }).age); // 0 // Person.create({ name: 'Charlie', age: 'old' }); // Error
Debug
Known issues
deprecatedPackage is effectively abandoned (last release 2016, no updates). Not compatible with modern React (prop-types package).
fix
Consider implementing similar validation manually or using TypeScript interfaces.
affects: 0.1.0
breakingUses React's internal PropTypes (React.PropTypes) which were deprecated in React v15.5. This package will not work with React >=16.
fix
Use the standalone 'prop-types' package and manually integrate validation.
affects: 0.1.0
gotchaThe mixin depends on 'redux-orm' as a peer dependency but does not list it in package.json peerDependencies. Expect runtime errors if redux-orm is missing.
fix
Install redux-orm separately: npm install redux-orm
affects: 0.1.0
gotchaIn production mode, all validation is silently disabled. This may hide bugs.
fix
Use getPropTypesMixin({ validate: true }) to force validation in all environments.
affects: 0.1.0
Errors
Common errors & fixes
Module not found: Can't resolve 'redux-orm-proptypes'
Package not installed or missing from node_modules.
fix
Run npm install redux-orm-proptypes --save
TypeError: propTypesMixin is not a function
Using named import instead of default import.
fix
Use import propTypesMixin from 'redux-orm-proptypes' (not { propTypesMixin }).
Uncaught Error: PropTypes is not defined
React PropTypes are accessed from React (old API). In modern React, PropTypes is a separate package.
fix
Install and import 'prop-types' package instead of relying on React.PropTypes.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
redux-ormrequiredPeer dependency, operates directly on redux-orm Model
reactoptionalUses PropTypes from React for validation
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
redux-orm-proptypes — npm install redux-orm-proptypes · libregistry