diff --git a/app/models/concerns/bulkrax/has_local_processing.rb b/app/models/concerns/bulkrax/has_local_processing.rb index 80edc3f2..57dec9fe 100644 --- a/app/models/concerns/bulkrax/has_local_processing.rb +++ b/app/models/concerns/bulkrax/has_local_processing.rb @@ -10,8 +10,18 @@ def add_local parsed_metadata['format'] = parse_format(parsed_metadata['format']) if parsed_metadata['format'] end + def form_class + return false unless parsed_metadata['model'].present? + @form_class ||= "Hyrax::#{parsed_metadata['model']}Form".constantize + end + + def validate?(attribute) + form_class.required_fields.include?(attribute) + end + def parse_year(src) src = src.strip.chomp + return src unless validate?(:year) valid = src.match?(/^(19|20)\d{2}$/) error_msg = %("#{src}" is not a 4 digit year.) valid ? src : (raise ::StandardError, error_msg) @@ -21,9 +31,12 @@ def parse_format(src) src.map do |format| # will return nil if it doesn't match with any format label label = Hyrax::FormatService.label_from_alt(format) - valid = label.present? - error_msg = %("#{format}" is not a valid type of format.) - valid ? label : (raise ::StandardError, error_msg) + if validate?(:format) + valid = label.present? + error_msg = %("#{format}" is not a valid type of format.) + raise(::StandardError, error_msg) unless valid + end + label end end end diff --git a/docker-compose.yml b/docker-compose.yml index 2577999a..31f1482f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -159,7 +159,7 @@ services: condition: service_started initialize_app: condition: service_completed_successfully - expose: + ports: - 3000 worker: