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
Refactor validations #6815
Refactor validations #6815
Changes from 4 commits
75b69e7
811571e
757fedc
e574c7f
60c7e92
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 |
---|---|---|
|
@@ -117,19 +117,14 @@ def states | |
before_create :link_by_email | ||
before_update :homogenize_line_item_currencies, if: :currency_changed? | ||
|
||
validates :number, presence: true, | ||
length: { maximum: 32, allow_blank: true }, | ||
uniqueness: { allow_blank: true } | ||
validates :email, presence: true, | ||
length: { maximum: 254, allow_blank: true }, | ||
email: { allow_blank: true }, | ||
if: :require_email | ||
validates :state, presence: true, | ||
inclusion: { in: state_machine.states.map { |state| state.name.to_s }, allow_blank: true } | ||
with_options presence: true do | ||
validates :number, length: { maximum: 32, allow_blank: true }, uniqueness: { allow_blank: true } | ||
validates :email, length: { maximum: 254, allow_blank: true }, email: { allow_blank: true }, if: :require_email | ||
validates :state, inclusion: { in: state_machine.states.map { |state| state.name.to_s }, allow_blank: true } | ||
validates :item_count, numericality: { greater_than_or_equal_to: 0, less_than: 2**31, only_integer: true, allow_blank: true } | ||
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. Line is too long. [131/120] |
||
end | ||
validates :payment_state, inclusion: { in: %w[balance_due paid credit_owed failed void], allow_blank: true } | ||
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. Create array directly like ['balance_due', 'paid', 'etc' ] rather than %w[balance_due paid etc] |
||
validates :shipment_state, inclusion: { in: %w[ready pending partial shipped backorder canceled], allow_blank: true } | ||
validates :item_count, presence: true, | ||
numericality: { greater_than_or_equal_to: 0, less_than: 2**31, only_integer: true, allow_blank: true } | ||
validates :item_total, POSITIVE_MONEY_VALIDATION | ||
validates :adjustment_total, MONEY_VALIDATION | ||
validates :included_tax_total, POSITIVE_MONEY_VALIDATION | ||
|
@@ -141,7 +136,7 @@ def states | |
|
||
validate :has_available_shipment | ||
|
||
delegate :update_totals, :persist_totals, :to => :updater | ||
delegate :update_totals, :persist_totals, to: :updater | ||
delegate :merge!, to: :merger | ||
delegate :firstname, :lastname, to: :bill_address, prefix: true, allow_nil: 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.
Line is too long. [145/120]