-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DPL-947 dna control barcode v12 sequel i ie #1143
Changes from 12 commits
435686a
f674d0d
eafc8d8
467f358
a1724c4
3efad7a
af9502c
a2a1fbe
901a103
1af74f7
2443e5a
dd78b8d
1272053
09a31b6
42b5272
40c76ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# Validator for required attributes | ||
# Validates the presence of required attributes | ||
# Validates the presence of required attributes and versions | ||
class RequiredAttributesValidator < ActiveModel::Validator | ||
attr_reader :required_attributes | ||
attr_reader :required_attributes, :versions | ||
|
||
# @param [Hash] options | ||
# @option options [Array] :required_attributes | ||
def initialize(options) | ||
super | ||
|
||
@versions = options[:versions] | ||
@required_attributes = options[:required_attributes] | ||
end | ||
|
||
|
@@ -24,8 +26,14 @@ def validate(record) | |
# @param [ActiveRecord::Base] record | ||
# @param [Symbol] required_attribute | ||
def validate_required_attribute(record, required_attribute) | ||
return if record.send(required_attribute).present? | ||
# If versions are specified, check that the record's smrt_link_version version | ||
# is included in the list | ||
if versions.present? && versions.exclude?(record.smrt_link_version.name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove this now. |
||
nil | ||
else | ||
return if record.send(required_attribute).present? | ||
|
||
record.errors.add(required_attribute, "can't be blank") | ||
record.errors.add(required_attribute, "can't be blank") | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Add feature flags to this file, example: | ||
# dpl202_enable_angry_cat_feature: When enabled this will add an angry cat to all pages that will try to catch the mouse pointer | ||
# The key should be lowecase and snake case, and prefixes with the issue number to allow easy identification | ||
|
||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,12 @@ default: &default | |
attribute: :plates | ||
minimum: 1 | ||
maximum: 1 | ||
# TODO: fix this to have separate behaviour for v11 and v12 (see commit 05bfe764a8eafe) | ||
required_attributes: | ||
options: | ||
versions: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can definitely remove the versions code but wait to hear back from Craig as to whether this needs to be required. It wasn't previously. |
||
- v12_sequel_iie | ||
required_attributes: | ||
- :dna_control_complex_box_barcode | ||
plates: | ||
children: :wells | ||
# we want to validate each plate and plate | ||
|
@@ -73,31 +78,31 @@ default: &default | |
options: | ||
exclude_marked_for_destruction: true | ||
valid_positions: | ||
- A1 | ||
- B1 | ||
- C1 | ||
- D1 | ||
- A1 | ||
- B1 | ||
- C1 | ||
- D1 | ||
well_combinations: | ||
invalid_combinations: | ||
- [A1,D1] | ||
- [A1,C1] | ||
- [B1,D1] | ||
- [A1,C1,D1] | ||
- [A1,B1,D1] | ||
- [D1,B1] | ||
- [A1, D1] | ||
- [A1, C1] | ||
- [B1, D1] | ||
- [A1, C1, D1] | ||
- [A1, B1, D1] | ||
- [D1, B1] | ||
options: | ||
exclude_marked_for_destruction: true | ||
valid_combinations: | ||
- [A1] | ||
- [A1,B1] | ||
- [A1,B1,C1] | ||
- [A1,B1,C1,D1] | ||
- [B1] | ||
- [B1,C1] | ||
- [B1,C1,D1] | ||
- [C1] | ||
- [C1,D1] | ||
- [D1] | ||
- [A1] | ||
- [A1, B1] | ||
- [A1, B1, C1] | ||
- [A1, B1, C1, D1] | ||
- [B1] | ||
- [B1, C1] | ||
- [B1, C1, D1] | ||
- [C1] | ||
- [C1, D1] | ||
- [D1] | ||
sequencing_kit_box_barcode: | ||
options: | ||
exclude_marked_for_destruction: true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Versions aren't needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed out. Removed now 👍