2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/models/project_validator.rb', line 2
def validate(project)
project.metadata = project.metadata_model
validate_role(project:, netid: project.metadata_model.data_manager, role: "Data Manager")
validate_role(project:, netid: project.metadata_model., role: "Data Sponsor")
project.metadata_model.data_user_read_only&.each { |read_only| validate_role(project:, netid: read_only, role: "Data User Read Only")}
project.metadata_model.data_user_read_write&.each { |read_write| validate_role(project:, netid: read_write, role: "Data User Read Write")}
required_metadata_field_errors = []
required_metadata = required_attributes(project:)
if required_metadata.values.include?(nil)
required_keys.each do |attr|
value = required_metadata[attr]
required_metadata_field_errors << "Missing metadata value for #{attr}" if value.nil? && project.metadata_json.include?(attr)
end
end
if required_metadata_field_errors.count > 0
project.errors.add :base, "Invalid Project Metadata it does not match the schema #{TigerdataSchema::SCHEMA_VERSION}\n #{required_metadata_field_errors.join(", ")}"
end
end
|