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