-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from Mth0158/213-incorrect-error-message-when…
…-validator-is-used-with-if-or-on 213 incorrect error message when validator is used with if or on
- Loading branch information
Showing
47 changed files
with
837 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module AspectRatio | ||
def self.table_name_prefix | ||
'aspect_ratio_' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module AspectRatio | ||
module Validator | ||
def self.table_name_prefix | ||
'aspect_ratio_validator_' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: aspect_ratio_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class AspectRatio::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, aspect_ratio: :square, if: -> { self.title == 'Right title' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: aspect_ratio_validator_with_ons | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class AspectRatio::Validator::WithOn < ApplicationRecord | ||
has_one_attached :with_on | ||
validates :with_on, aspect_ratio: :square, on: %i(create update destroy custom) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Attached | ||
module Validator | ||
def self.table_name_prefix | ||
'attached_validator_' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: attached_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Attached::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, attached: true, if: -> { self.title == 'Right title' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: attached_validator_with_ons | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Attached::Validator::WithOn < ApplicationRecord | ||
has_one_attached :with_on | ||
validates :with_on, attached: true, on: %i(create update destroy custom) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ContentType | ||
module Validator | ||
def self.table_name_prefix | ||
'content_type_validator_' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: content_type_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class ContentType::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, content_type: :webp, if: -> { self.title == 'Right title' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: content_type_validator_with_on | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class ContentType::Validator::WithOn < ApplicationRecord | ||
has_one_attached :with_on | ||
validates :with_on, content_type: :webp, on: %i(create update destroy custom) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Dimension | ||
module Validator | ||
def self.table_name_prefix | ||
'dimension_validator_' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: dimension_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Dimension::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, dimension: { width: 150, height: 150 }, if: -> { self.title == 'Right title' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: dimension_validator_with_ons | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Dimension::Validator::WithOn < ApplicationRecord | ||
has_one_attached :with_on | ||
validates :with_on, dimension: { width: 150, height: 150 }, on: %i(create update destroy custom) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Limit | ||
def self.table_name_prefix | ||
'limit_' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Limit | ||
module Validator | ||
def self.table_name_prefix | ||
'limit_validator_' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: limit_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Limit::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, limit: { min: 1 }, if: -> { self.title == 'Right title' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: limit_validator_with_ons | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Limit::Validator::WithOn < ApplicationRecord | ||
has_one_attached :with_on | ||
validates :with_on, limit: { min: 1 }, on: %i(create update destroy custom) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ProcessableImage | ||
def self.table_name_prefix | ||
'processable_image_' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ProcessableImage | ||
module Validator | ||
def self.table_name_prefix | ||
'processable_image_validator_' | ||
end | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
test/dummy/app/models/processable_image/validator/with_if.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: processable_image_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class ProcessableImage::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, processable_image: true, if: -> { self.title == 'Right title' } | ||
end |
15 changes: 15 additions & 0 deletions
15
test/dummy/app/models/processable_image/validator/with_on.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: processable_image_validator_with_ons | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class ProcessableImage::Validator::WithOn < ApplicationRecord | ||
has_one_attached :with_on | ||
validates :with_on, processable_image: true, on: %i(create update destroy custom) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Size | ||
module Validator | ||
def self.table_name_prefix | ||
'size_validator_' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: size_validator_with_ifs | ||
# | ||
# title :string | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Size::Validator::WithIf < ApplicationRecord | ||
has_one_attached :with_if | ||
validates :with_if, size: { less_than: 2.kilobytes }, if: -> { self.title == 'Right title' } | ||
end |
Oops, something went wrong.