React Prop Types URL Validator
npm install url-prop-type



!npm bundle size

!GitHub
https://github.com/jaebradley/url-prop-type) or a relative-absolute URL (starts with a /).Currently, there is no URL prop type defined by the prop-types package. While using PropType.string works, why not be as specific as possible when validating your props?
Additionally, though it's relatively straightforward to create a custom prop type validator, if you need to implement similar prop type checking in multiple packages, you might not want to repeat yourself.
Depends on the is-url package.
npm install --save url-prop-typejavascript
import React from 'react';
import PropTypes from 'prop-types';
import urlPropType from 'url-prop-type';// Create a basic Hyperlink Component
const Hyperlink = props => ( {props.text} );
Hyperlink.propTypes = {
text: PropTypes.string.isRequired,
link: urlPropType.isRequired, // can also specify urlPropType if it is not required
};
`Alternatives
I didn't see many alternatives:
* It doesn't look like the airbnb/prop-types project has URL validation.
* Opened this PR with airbnb/proptypes
* Similarly, the react-proptypes-url-validator package doesn't seem to implement an isRequired` option