Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extended-proptypes

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extended-proptypes

Useful proptypes for react components

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-17.95%
Maintainers
1
Weekly downloads
 
Created
Source

Extended Prop Types

Useful proptypes for React components. Developed for and tested on ClassDojo's web app.

Usage

Call the exported function on the standard React proptypes object.

import {PropTypes} from "react";
import ExtendPropTypes from "extended-proptypes";

ExtendPropTypes(PropTypes);

New options will now be available on React's PropTypes export.

import {Component, PropTypes} from "react";

class MyComponent extends Component {
  
  static propTypes = {
    myDate: PropTypes.date,
    mySatanicString: PropTypes.stringMatching(/^6+$/).isRequired,
    myArrayOrObject: PropTypes.iterableOf(PropTypes.bool),
  };
}

New Prop Types

All validators expose basic and isRequired versions.

Collections

  • iterable: An array or an object.
  • iterableOf(validator): An array or object whose values match the provided validator.
  • keyedObject(regex): An object whose keys match the provided regex.
  • keyedObjectOf(regex, validator): An object whose keys match the provided regex and whose values match the provided validator.

General Primatives

  • stringMatching(regex): A string that matches the provided regex.
  • stringWithLength(min, max=Infinity): A string with length between min and max.
  • time: A value parsable by new Date().
  • uuid: A uuid string.
  • locale: A locale string, like en-US or jp
  • emailAddress: An email address (regex taken from the highest-upvoted SO answer)

CSS

  • percent: A percentage.
  • cssLength: A single css length, like 24px, 43% or 4rem.
  • cssSize: Between 1 and 4 css sizes.
  • color: A hex or rgb(a) string

MongoDB-specific

  • mongoId: A 24-character hex string.
  • mongoIdKeyedObject: An object whose keys are mongo ids.
  • mongoIdKeyedObjectOf(validator): An object whose keys are mongo ids and whose values match the provided validator.

Upcoming

  • Single exports
  • Use without extending

Keywords

FAQs

Package last updated on 14 Apr 2016

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