import { Requireable , Validator } from 'prop-types' ; export const createPropType = < T > ( getValue ) : Requireable < T > => { const propType = ( props , propName , componentName ) => { const propValue = props [ propName ] ; if ( propValue === undefined || getValue ( propValue ) !== undefined ) { return null ; } return new Error ( `Invalid value for prop \`${ propName }\` supplied to \`${ componentName }\`: \`${ propValue }\`` ) ; } ; const isRequired = ( props , propName , componentName ) => { const propValue = props [ propName ] ; if ( propValue !== undefined && getValue ( propValue ) !== undefined ) { return null ; } return new Error ( `Invalid value for prop \`${ propName }\` supplied to \`${ componentName }\`: \`${ propValue }\`` ) ; } ; return Object . assign ( propType , { isRequired } ) ; } ;