doi-prop-type

1.1.0 • Public • Published

DOI Prop Type

Build npm GitHub

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
};

Readme

Keywords

Package Sidebar

Install

npm i doi-prop-type

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

5.18 kB

Total Files

13

Last publish

Collaborators

  • ja573