From 7bd3b1e01c8116208e71718ee840d2f8334fc16e Mon Sep 17 00:00:00 2001 From: xzo Date: Sun, 10 Jan 2016 10:55:27 +0300 Subject: [PATCH 1/2] Fix ValidationHelpers docs: bad examples --- lib/shrine/plugins/validation_helpers.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/shrine/plugins/validation_helpers.rb b/lib/shrine/plugins/validation_helpers.rb index f64137fe4..0f772ba0f 100644 --- a/lib/shrine/plugins/validation_helpers.rb +++ b/lib/shrine/plugins/validation_helpers.rb @@ -28,7 +28,7 @@ module Plugins # If you would like to change the error message inline, you can pass the # `:message` option to any validation method: # - # validate_mime_type_inclusion [/^image/], message: "is not an image" + # validate_mime_type_inclusion [/\Aimage/], message: "is not an image" # # For a complete list of all validation helpers, see AttacherMethods. module ValidationHelpers @@ -110,7 +110,7 @@ def validate_min_height(min, message: nil) # Validates that the MIME type is in the `whitelist`. The whitelist is # an array of strings or regexes. # - # validate_mime_type_inclusion ["audio/mp3", /^video/] + # validate_mime_type_inclusion ["audio/mp3", /\Avideo/] def validate_mime_type_inclusion(whitelist, message: nil) if whitelist.none? { |mime_type| regex(mime_type) =~ get.mime_type.to_s } errors << error_message(:mime_type_inclusion, message, whitelist) @@ -120,7 +120,7 @@ def validate_mime_type_inclusion(whitelist, message: nil) # Validates that the MIME type is not in the `blacklist`. The blacklist # is an array of strings or regexes. # - # validate_mime_type_exclusion ["image/gif", /^audio/] + # validate_mime_type_exclusion ["image/gif", /\Aaudio/] def validate_mime_type_exclusion(blacklist, message: nil) if blacklist.any? { |mime_type| regex(mime_type) =~ get.mime_type.to_s } errors << error_message(:mime_type_exclusion, message, blacklist) @@ -130,7 +130,7 @@ def validate_mime_type_exclusion(blacklist, message: nil) # Validates that the extension is in the `whitelist`. The whitelist # is an array of strings or regexes. # - # validate_extension_inclusion [/jpe?g/] + # validate_extension_inclusion [/\Ajpe?g\z/i] def validate_extension_inclusion(whitelist, message: nil) if whitelist.none? { |extension| regex(extension) =~ get.extension.to_s } errors << error_message(:extension_inclusion, message, whitelist) @@ -140,7 +140,7 @@ def validate_extension_inclusion(whitelist, message: nil) # Validates that the extension is not in the `blacklist`. The blacklist # is an array of strings or regexes. # - # validate_extension_exclusion ["mov", /^mp*/] + # validate_extension_exclusion ["mov", /\Amp/] def validate_extension_exclusion(blacklist, message: nil) if blacklist.any? { |extension| regex(extension) =~ get.extension.to_s } errors << error_message(:extension_exclusion, message, blacklist) From 9567983c9b397cd1a42575ba28d1d877ab6490b1 Mon Sep 17 00:00:00 2001 From: xzo Date: Sun, 10 Jan 2016 11:13:31 +0300 Subject: [PATCH 2/2] Update validation_helpers.rb --- lib/shrine/plugins/validation_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shrine/plugins/validation_helpers.rb b/lib/shrine/plugins/validation_helpers.rb index 0f772ba0f..1c29dfd9d 100644 --- a/lib/shrine/plugins/validation_helpers.rb +++ b/lib/shrine/plugins/validation_helpers.rb @@ -140,7 +140,7 @@ def validate_extension_inclusion(whitelist, message: nil) # Validates that the extension is not in the `blacklist`. The blacklist # is an array of strings or regexes. # - # validate_extension_exclusion ["mov", /\Amp/] + # validate_extension_exclusion ["mov", /\Amp/i] def validate_extension_exclusion(blacklist, message: nil) if blacklist.any? { |extension| regex(extension) =~ get.extension.to_s } errors << error_message(:extension_exclusion, message, blacklist)