New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-generic-proptypes

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-generic-proptypes

React proptype checker for generic usage

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

react-generic-proptypes

Build Status

A React Proptype Validator to check if passed prop is following generic predicates

Allows multiple validation steps with different messages

Example

var genericProptype = require('react-generic-proptypes').genericProptype;

const TestClass = React.createClass({
  propTypes : {
    testSimpleProp : genericProptype(
      'object',
      function(obj) {
        return typeof obj === 'object';
      },
      function (obj) {
        return obj && obj.foo === 456;
      }
    ),
    testComplexProp : genericProptype(
      'object',
      function(obj) {
        return typeof obj === 'object';
      },
      [
        function firstFunction(obj) {
          return true;
        },
        {
          validationPredicate: function(obj) {
            return true;
          },
        },
        {
          failureMessage: 'Custom error message appended to warning',
          validationPredicate: function shouldNeverReach(obj) {
            return true;
          },
        },
      ],
    ),
  },
  render() {
    return null;
  },
});

// Class Use
<TestClass testSimpleProp={{ 'test': 1 }}
           testComplexProp={{ foo: 456 }} />

Tests

  • npm test for running unit tests
  • npm run coverage for current test coverage

Keywords

FAQs

Package last updated on 13 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc