RobSullivan / pmc-ref

Check an article's references for free access.
https://pmc-ref.herokuapp.com/
MIT License
8 stars 3 forks source link

Validate doi format before requesting data #1

Open RobSullivan opened 9 years ago

RobSullivan commented 9 years ago

At the moment it is possible to submit an incorrectly formatted doi and the request will be submitted.

To save on requesting an incorrectly formatted doi It might be better to check the format first.

One way to achieve this is with a regular expression.

Regex taken from this SO answer http://stackoverflow.com/a/10324802

Test it here https://regex101.com/r/uQ0fW8/1

Possible validating could take place here https://github.com/RobSullivan/pmc-ref/blob/master/routes/get_articles.js#L9

RobSullivan commented 8 years ago

DOI format validation should happen before user submits doi.