Class: Identifier::Global::MorphbankSpecimenNumber

Inherits:
Identifier::Global show all
Defined in:
app/models/identifier/global/morphbank_specimen_number.rb

Overview

For use with Morphbank specimens, currently just a number e.g. 855664

Constant Summary

Constant Summary

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from Identifier::Global

#relation

Attributes inherited from Identifier

#cached, #identifier, #identifier_object_id, #namespace_id, #project_id, #type

Instance Method Summary (collapse)

Methods inherited from Identifier::Global

#permit_only_one_global_without_relation_supplied_per_type, #set_cached, #sv_resolves?

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Methods inherited from Identifier

find_for_autocomplete, prototype_identifier, #set_cached, #type_name

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Instance Method Details

- (Object) is_number



7
8
9
10
11
12
13
14
# File 'app/models/identifier/global/morphbank_specimen_number.rb', line 7

def is_number
  if identifier.present?
    # If non-number characters are in the string, invalid format
    if /\D/.match(identifier)
      errors.add(:identifier, 'invalid format, only numbers allowed')
    end
  end
end