class DogBiscuits::LabelValidator
Validates that there is a rdfs label/preflabel (authorities) or title (works etc.) FileSet
is not validated - title and/or label are optional
Public Instance Methods
validate(record)
click to toggle source
# File lib/dog_biscuits/validators/label_validator.rb, line 7 def validate(record) if record.work? validate_title(record) elsif record.collection? validate_title(record) elsif record.authority? validate_authority(record) end end
validate_agent(record)
click to toggle source
# File lib/dog_biscuits/validators/label_validator.rb, line 31 def validate_agent(record) if record.person? validate_person(record) elsif record.rdfs_label.blank? && record.name.blank? record.errors[:rdfs_label] << 'You must provide a rdfs label or name for agents' end end
validate_label(record)
click to toggle source
# File lib/dog_biscuits/validators/label_validator.rb, line 51 def validate_label(record) record.errors[:rdfs_label] << 'You must provide a preflabel or rdfs label' if record.preflabel.blank? && record.rdfs_label.blank? end
validate_person(record)
click to toggle source
# File lib/dog_biscuits/validators/label_validator.rb, line 39 def validate_person(record) record.errors[:rdfs_label] << 'You must provide a rdfs label or name for people' if record.rdfs_label.blank? && record.given_name.blank? && record.family_name.blank? && record.name.blank? end
validate_place(record)
click to toggle source
# File lib/dog_biscuits/validators/label_validator.rb, line 43 def validate_place(record) record.errors[:rdfs_label] << 'You must provide a rdfs label or name for places' if record.rdfs_label.blank? && record.place_name.blank? end
validate_title(record)
click to toggle source
# File lib/dog_biscuits/validators/label_validator.rb, line 47 def validate_title(record) record.errors[:title] << 'You must provide a title' if record.title.blank? end