Skip to content
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

pass options to errors.add as kwargs #50

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def validate_blacklist(record, attribute, value)
end

def mark_invalid(record, attribute, types)
record.errors.add attribute, :invalid, options.merge(types: types.join(", "))
record.errors.add attribute, :invalid, **options.merge(types: types.join(", "))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [87/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

def allowed_types
Expand Down
2 changes: 1 addition & 1 deletion lib/paperclip/validators/attachment_file_name_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def validate_blacklist(record, attribute, value)
end

def mark_invalid(record, attribute, patterns)
record.errors.add attribute, :invalid, options.merge(names: patterns.join(", "))
record.errors.add attribute, :invalid, **options.merge(names: patterns.join(", "))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [90/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

def allowed
Expand Down
2 changes: 1 addition & 1 deletion lib/paperclip/validators/attachment_presence_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Paperclip
module Validators
class AttachmentPresenceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, _value)
record.errors.add(attribute, :blank, options) if record.send("#{attribute}_file_name").blank?
record.errors.add(attribute, :blank, **options) if record.send("#{attribute}_file_name").blank?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [103/80]

end

def self.helper_method_name
Expand Down
2 changes: 1 addition & 1 deletion lib/paperclip/validators/attachment_size_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def validate_each(record, attr_name, value)
unless value.send(CHECKS[option], option_value)
error_message_key = options[:in] ? :in_between : option
error_attrs.each do |error_attr_name|
record.errors.add(error_attr_name, error_message_key, filtered_options(value).merge(
record.errors.add(error_attr_name, error_message_key, **filtered_options(value).merge(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [102/80]

min: min_value_in_human_size(record),
max: max_value_in_human_size(record),
count: human_size(option_value)
Expand Down