Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.
/ check-prop-type Public archive

Run a prop type against a value and return any warnings

Notifications You must be signed in to change notification settings

n3dst4/check-prop-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

check-prop-type

Travis Status

Run a prop type against a value and return any warnings

Installation

npm install check-prop-type --save

Usage

checkPropType(propType, value)

Returns a string containing an error if the given prop-type is not valid for the given value.

Returns null otherwise.

Examples (adadpted from the test suite):

import checkPropType from "check-prop-type"

const result = checkPropType(PropTypes.string, 1)
expect(result).to.be.a("string")

const result = checkPropType(PropTypes.string, "asd")
expect(result).to.be.null

const result = checkPropType(PropTypes.string.isRequired, undefined)
expect(result).to.be.a("string")

About

Run a prop type against a value and return any warnings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published