Sha256: b38dc75ef13fea8ed6c23d883a2d9fc57e47e5184718312b0cfaa173cf35848d

Contents?: true

Size: 363 Bytes

Versions: 32

Compression:

Stored size: 363 Bytes

Contents

module Sufia
  class OrcidValidator < ActiveModel::Validator
    def validate(record)
      return if record.orcid.blank?
      record.errors.add(:orcid, 'must be a string of 19 characters, e.g., "0000-0000-0000-0000"') unless self.class.match(record.orcid)
    end

    def self.match(string)
      /\d{4}-\d{4}-\d{4}-\d{3}[\dX]/.match(string)
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
sufia-7.4.1 app/models/sufia/orcid_validator.rb
sufia-7.4.0 app/models/sufia/orcid_validator.rb
sufia-7.3.1 app/models/sufia/orcid_validator.rb
sufia-7.3.0 app/models/sufia/orcid_validator.rb
sufia-7.3.0.rc3 app/models/sufia/orcid_validator.rb
sufia-7.3.0.rc2 app/models/sufia/orcid_validator.rb
sufia-7.3.0.rc1 app/models/sufia/orcid_validator.rb
sufia-7.2.0 app/models/sufia/orcid_validator.rb
sufia-models-6.7.0 app/models/sufia/orcid_validator.rb
sufia-7.1.0 app/models/sufia/orcid_validator.rb
sufia-7.0.0 app/models/sufia/orcid_validator.rb
sufia-7.0.0.rc2 app/models/sufia/orcid_validator.rb
sufia-7.0.0.rc1 app/models/sufia/orcid_validator.rb
sufia-7.0.0.beta4 app/models/sufia/orcid_validator.rb
sufia-7.0.0.beta3 app/models/sufia/orcid_validator.rb
sufia-7.0.0.beta2 app/models/sufia/orcid_validator.rb
sufia-7.0.0.beta1 app/models/sufia/orcid_validator.rb
sufia-models-6.6.1 app/models/sufia/orcid_validator.rb
sufia-models-6.6.0 app/models/sufia/orcid_validator.rb
sufia-models-6.5.0 app/models/sufia/orcid_validator.rb