Skip to content

Commit

Permalink
validate ROR ID
Browse files Browse the repository at this point in the history
  • Loading branch information
whomingbird committed Dec 13, 2024
1 parent 0dc8740 commit 6166a48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/institution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Institution < ApplicationRecord
validates :web_page, url: { allow_nil: true, allow_blank: true }
validates :country, country: true


VALID_ROR_ID_REGEX = /\A[0-9a-zA-Z]{9}\z/
validates :ror_id, format: { with: VALID_ROR_ID_REGEX, message: 'is invalid.' }, allow_blank: true

has_many :work_groups, dependent: :destroy, inverse_of: :institution
has_many :projects, through: :work_groups, inverse_of: :institutions
has_many :programmes, -> { distinct }, through: :projects, inverse_of: :institutions
Expand Down

0 comments on commit 6166a48

Please sign in to comment.