Package Exports
- doi-prop-type
- doi-prop-type/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (doi-prop-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
DOI Prop Type
This package is used to validate if a React Prop value is a valid DOI, e.g. 10.11647/obp.0229. To do so we compare the input against this regex: /^10.\d{4,9}\/[-._\;\(\)\/:a-zA-Z0-9]+$/g.
The prop-types package does not support a DOI prop type, therefore you can use this package to validate them, instead of using the permissive PropType.string.
Installation
npm install --save doi-prop-type
Example Usage
import React from 'react';
import doiPropType from 'doi-prop-type';
// Create a generic component
const Doi = props => ( <a href={`https://doi.org/${props.doi}`}>{props.doi}</a> );
Doi.propTypes = {
doi: doiPropType.isRequired, // can also specify doiPropType if it is not required
};