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

airbnb-prop-types

Package Overview
Dependencies
Maintainers
7
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airbnb-prop-types

Custom React PropType validators that we use at Airbnb.

  • 2.16.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created

What is airbnb-prop-types?

The airbnb-prop-types package provides a collection of React propType validators that can be used to ensure that components receive props of the correct type, shape, and value. It extends the basic propTypes provided by React with more specific and useful validators, making it easier to catch bugs and enforce consistent prop usage across a codebase.

What are airbnb-prop-types's main functionalities?

Primitive Type Validators

Allows for more specific type validation, such as ensuring a prop is a non-empty string.

import { string } from 'airbnb-prop-types';
Component.propTypes = {
  name: string().isRequired,
};

Collection Validators

Enables validation of arrays, ensuring each item in the array matches the specified validator.

import { arrayOf } from 'airbnb-prop-types';
Component.propTypes = {
  items: arrayOf(string()).isRequired,
};

Shape Validators

Allows for the validation of an object's shape, ensuring it matches a specific schema.

import { shape } from 'airbnb-prop-types';
Component.propTypes = {
  user: shape({
    id: number().isRequired,
    name: string().isRequired,
  }).isRequired,
};

Custom Validators

Provides the ability to create custom validators, such as forbidding extra props that are not explicitly specified.

import { forbidExtraProps } from 'airbnb-prop-types';
Component.propTypes = forbidExtraProps({
  name: string().isRequired,
  age: number(),
});

Other packages similar to airbnb-prop-types

Keywords

FAQs

Package last updated on 30 Jun 2020

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