1.1.0 • Published 3 years ago

doi-prop-type v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

3 years ago

1.0.2

4 years ago

1.0.0

4 years ago