-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validates doi name only when doi doesn't exist already
DOI exists -> validation of metadata with DOI name containing a + sign should pass DOI does not exist -> validation of metadata with DOI name containing a + sign should fail fix datacite/bracco#189
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ class Doi < ActiveRecord::Base | |
|
||
attribute :regenerate, :boolean, default: false | ||
attribute :only_validate, :boolean, default: false | ||
attribute :exists, :boolean, default: false | ||
attribute :should_validate, :boolean, default: false | ||
attribute :agency, :string, default: "DataCite" | ||
|
||
|
@@ -77,7 +78,7 @@ class Doi < ActiveRecord::Base | |
# validates_presence_of :url, if: :is_registered_or_findable? | ||
|
||
# from https://www.crossref.org/blog/dois-and-matching-regular-expressions/ but using uppercase | ||
validates_format_of :doi, :with => /\A10\.\d{4,5}\/[-\._;()\/:a-zA-Z0-9\*~\$\=]+\z/, :on => :create | ||
validates_format_of :doi, :with => /\A10\.\d{4,5}\/[-\._;()\/:a-zA-Z0-9\*~\$\=]+\z/, :on => :create, unless: :exists | ||
This comment has been minimized.
Sorry, something went wrong.
mfenner
Contributor
|
||
validates_format_of :url, :with => /\A(ftp|http|https):\/\/[\S]+/ , if: :url?, message: "URL is not valid" | ||
validates_uniqueness_of :doi, message: "This DOI has already been taken", unless: :only_validate | ||
validates :last_landing_page_status, numericality: { only_integer: true }, if: :last_landing_page_status? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Why create new DOI when DOI already exists?