diff --git a/app/models/doi.rb b/app/models/doi.rb index ccf0b2ee9..a1b18a172 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -81,7 +81,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/ + validates_format_of :doi, :with => /\A10\.\d{4,5}\/[-\._;()\/:a-zA-Z0-9]+\z/, :on => :create 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" validates :last_landing_page_status, numericality: { only_integer: true }, if: :last_landing_page_status?