From fa34e45fc21fe4fa1a21f4ee75d994987ff836ef Mon Sep 17 00:00:00 2001 From: Cosmin Barbu Date: Wed, 4 Oct 2017 14:51:44 +0300 Subject: [PATCH 1/3] Extract messages into separate classes in order to allow user to have custom messages --- .../error_messages/base_message.rb | 12 +++++++ .../cannot_be_greater_than_message.rb | 9 +++++ .../cannot_be_less_than_message.rb | 9 +++++ .../error_messages/is_blank_message.rb | 9 +++++ .../error_messages/is_required_message.rb | 9 +++++ .../must_be_a_string_message.rb | 9 +++++ .../error_messages/must_be_equal_message.rb | 9 +++++ .../error_messages/must_be_within_message.rb | 9 +++++ .../must_have_length_greater_than_message.rb | 9 +++++ .../must_have_length_less_than_message.rb | 9 +++++ .../must_match_regex_message.rb | 9 +++++ lib/rails_param/param.rb | 35 ++++++++++--------- spec/rails_param/param_spec.rb | 12 +++++++ 13 files changed, 132 insertions(+), 17 deletions(-) create mode 100644 lib/rails_param/error_messages/base_message.rb create mode 100644 lib/rails_param/error_messages/cannot_be_greater_than_message.rb create mode 100644 lib/rails_param/error_messages/cannot_be_less_than_message.rb create mode 100644 lib/rails_param/error_messages/is_blank_message.rb create mode 100644 lib/rails_param/error_messages/is_required_message.rb create mode 100644 lib/rails_param/error_messages/must_be_a_string_message.rb create mode 100644 lib/rails_param/error_messages/must_be_equal_message.rb create mode 100644 lib/rails_param/error_messages/must_be_within_message.rb create mode 100644 lib/rails_param/error_messages/must_have_length_greater_than_message.rb create mode 100644 lib/rails_param/error_messages/must_have_length_less_than_message.rb create mode 100644 lib/rails_param/error_messages/must_match_regex_message.rb diff --git a/lib/rails_param/error_messages/base_message.rb b/lib/rails_param/error_messages/base_message.rb new file mode 100644 index 0000000..b5c05e6 --- /dev/null +++ b/lib/rails_param/error_messages/base_message.rb @@ -0,0 +1,12 @@ +module RailsParam + module ErrorMessages + class BaseMessage + attr_accessor :param_name, :value + + def initialize(param_name, value = nil) + @param_name = param_name + @value = value + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/cannot_be_greater_than_message.rb b/lib/rails_param/error_messages/cannot_be_greater_than_message.rb new file mode 100644 index 0000000..2f08ea4 --- /dev/null +++ b/lib/rails_param/error_messages/cannot_be_greater_than_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class CannotBeGreaterThanMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} cannot be greater than #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/cannot_be_less_than_message.rb b/lib/rails_param/error_messages/cannot_be_less_than_message.rb new file mode 100644 index 0000000..d9a36ab --- /dev/null +++ b/lib/rails_param/error_messages/cannot_be_less_than_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class CannotBeLessThanMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} cannot be less than #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/is_blank_message.rb b/lib/rails_param/error_messages/is_blank_message.rb new file mode 100644 index 0000000..9f3bdd7 --- /dev/null +++ b/lib/rails_param/error_messages/is_blank_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class IsRequiredMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} is required" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/is_required_message.rb b/lib/rails_param/error_messages/is_required_message.rb new file mode 100644 index 0000000..3e438c7 --- /dev/null +++ b/lib/rails_param/error_messages/is_required_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class IsBlankMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} cannot be blank" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/must_be_a_string_message.rb b/lib/rails_param/error_messages/must_be_a_string_message.rb new file mode 100644 index 0000000..24ceb5a --- /dev/null +++ b/lib/rails_param/error_messages/must_be_a_string_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class MustBeAStringMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} must be a string if using the format validation" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/must_be_equal_message.rb b/lib/rails_param/error_messages/must_be_equal_message.rb new file mode 100644 index 0000000..d59d5ba --- /dev/null +++ b/lib/rails_param/error_messages/must_be_equal_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class MustBeEqualMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} must be #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/must_be_within_message.rb b/lib/rails_param/error_messages/must_be_within_message.rb new file mode 100644 index 0000000..b93fc4d --- /dev/null +++ b/lib/rails_param/error_messages/must_be_within_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class MustBeWithinMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} must be within #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/must_have_length_greater_than_message.rb b/lib/rails_param/error_messages/must_have_length_greater_than_message.rb new file mode 100644 index 0000000..67e78a3 --- /dev/null +++ b/lib/rails_param/error_messages/must_have_length_greater_than_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class MustHaveLengthGreaterThanMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} cannot have length greater than #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/must_have_length_less_than_message.rb b/lib/rails_param/error_messages/must_have_length_less_than_message.rb new file mode 100644 index 0000000..74a2d73 --- /dev/null +++ b/lib/rails_param/error_messages/must_have_length_less_than_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class MustHaveLengthLessThanMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} cannot have length less than #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/error_messages/must_match_regex_message.rb b/lib/rails_param/error_messages/must_match_regex_message.rb new file mode 100644 index 0000000..d948505 --- /dev/null +++ b/lib/rails_param/error_messages/must_match_regex_message.rb @@ -0,0 +1,9 @@ +module RailsParam + module ErrorMessages + class MustMatchRegexMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} must match format #{value}" + end + end + end +end \ No newline at end of file diff --git a/lib/rails_param/param.rb b/lib/rails_param/param.rb index f8968ce..87003fe 100644 --- a/lib/rails_param/param.rb +++ b/lib/rails_param/param.rb @@ -116,36 +116,37 @@ def validate!(param, param_name, options) options.each do |key, value| case key when :required - raise InvalidParameterError, "Parameter #{param_name} is required" if value && param.nil? + raise InvalidParameterError, ::RailsParam::ErrorMessages::IsRequiredMessage.new(param_name).to_s if value && param.nil? when :blank - raise InvalidParameterError, "Parameter #{param_name} cannot be blank" if !value && case param - when String - !(/\S/ === param) - when Array, Hash - param.empty? - else - param.nil? - end + + raise InvalidParameterError, ::RailsParam::ErrorMessages::IsBlankMessage.new(param_name).to_s if !value && case param + when String + !(/\S/ === param) + when Array, Hash + param.empty? + else + param.nil? + end when :format - raise InvalidParameterError, "Parameter #{param_name} must be a string if using the format validation" unless param.kind_of?(String) - raise InvalidParameterError, "Parameter #{param_name} must match format #{value}" unless param =~ value + raise InvalidParameterError, ::RailsParam::ErrorMessages::MustBeAStringMessage.new(param_name).to_s unless param.kind_of?(String) + raise InvalidParameterError, ::RailsParam::ErrorMessages::MustMatchRegexMessage.new(param_name,value).to_s unless param =~ value when :is - raise InvalidParameterError, "Parameter #{param_name} must be #{value}" unless param === value + raise InvalidParameterError, ::RailsParam::ErrorMessages::MustBeEqualMessage.new(param_name, value).to_s unless param === value when :in, :within, :range - raise InvalidParameterError, "Parameter #{param_name} must be within #{value}" unless param.nil? || case value + raise InvalidParameterError,::RailsParam::ErrorMessages::MustBeWithinMessage.new(param_name, value).to_s unless param.nil? || case value when Range value.include?(param) else Array(value).include?(param) end when :min - raise InvalidParameterError, "Parameter #{param_name} cannot be less than #{value}" unless param.nil? || value <= param + raise InvalidParameterError, ::RailsParam::ErrorMessages::CannotBeLessThanMessage.new(param_name, value).to_s unless param.nil? || value <= param when :max - raise InvalidParameterError, "Parameter #{param_name} cannot be greater than #{value}" unless param.nil? || value >= param + raise InvalidParameterError, ::RailsParam::ErrorMessages::CannotBeGreaterThanMessage.new(param_name, value).to_s unless param.nil? || value >= param when :min_length - raise InvalidParameterError, "Parameter #{param_name} cannot have length less than #{value}" unless param.nil? || value <= param.length + raise InvalidParameterError, ::RailsParam::ErrorMessages::MustHaveLengthLessThanMessage.new(param_name, value).to_s unless param.nil? || value <= param.length when :max_length - raise InvalidParameterError, "Parameter #{param_name} cannot have length greater than #{value}" unless param.nil? || value >= param.length + raise InvalidParameterError, ::RailsParam::ErrorMessages::MustHaveLengthGreaterThanMessage.new(param_name, value).to_s unless param.nil? || value >= param.length end end end diff --git a/spec/rails_param/param_spec.rb b/spec/rails_param/param_spec.rb index 3972258..f1d4c3a 100644 --- a/spec/rails_param/param_spec.rb +++ b/spec/rails_param/param_spec.rb @@ -1,3 +1,15 @@ +require 'rails_param/error_messages/base_message' +require 'rails_param/error_messages/cannot_be_greater_than_message' +require 'rails_param/error_messages/cannot_be_less_than_message' +require 'rails_param/error_messages/is_blank_message' +require 'rails_param/error_messages/is_required_message' +require 'rails_param/error_messages/must_be_a_string_message' +require 'rails_param/error_messages/must_be_equal_message' +require 'rails_param/error_messages/must_be_within_message' +require 'rails_param/error_messages/must_have_length_greater_than_message' +require 'rails_param/error_messages/must_have_length_less_than_message' +require 'rails_param/error_messages/must_match_regex_message' + require 'rails_param/param' require 'action_controller' From 7b59459145911e67c846d9f25a928bdba46d9127 Mon Sep 17 00:00:00 2001 From: Cosmin Barbu Date: Wed, 4 Oct 2017 15:47:04 +0300 Subject: [PATCH 2/3] Add custom message support --- .gitignore | 1 + lib/rails_param/param.rb | 121 ++++++++++++++++++++++++++------- spec/rails_param/param_spec.rb | 70 +++++++++++++++++++ 3 files changed, 169 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index f66a096..1169efe 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ README.html .bundle Gemfile.lock *.gem +.idea \ No newline at end of file diff --git a/lib/rails_param/param.rb b/lib/rails_param/param.rb index 87003fe..0f05298 100644 --- a/lib/rails_param/param.rb +++ b/lib/rails_param/param.rb @@ -116,40 +116,115 @@ def validate!(param, param_name, options) options.each do |key, value| case key when :required - raise InvalidParameterError, ::RailsParam::ErrorMessages::IsRequiredMessage.new(param_name).to_s if value && param.nil? + raise_param_required(param, param_name, value, options[:message]) when :blank - - raise InvalidParameterError, ::RailsParam::ErrorMessages::IsBlankMessage.new(param_name).to_s if !value && case param - when String - !(/\S/ === param) - when Array, Hash - param.empty? - else - param.nil? - end + raise_blank_param(param, param_name, value, options[:message]) when :format - raise InvalidParameterError, ::RailsParam::ErrorMessages::MustBeAStringMessage.new(param_name).to_s unless param.kind_of?(String) - raise InvalidParameterError, ::RailsParam::ErrorMessages::MustMatchRegexMessage.new(param_name,value).to_s unless param =~ value + raise_param_should_be_string(param, param_name, options[:message]) + raise_param_should_match_regex(param, param_name, value, options[:message]) when :is - raise InvalidParameterError, ::RailsParam::ErrorMessages::MustBeEqualMessage.new(param_name, value).to_s unless param === value + raise_param_must_be_equal(param, param_name, value, options[:message]) when :in, :within, :range - raise InvalidParameterError,::RailsParam::ErrorMessages::MustBeWithinMessage.new(param_name, value).to_s unless param.nil? || case value - when Range - value.include?(param) - else - Array(value).include?(param) - end + raise_param_should_be_within_range(param, param_name, value, options[:message]) when :min - raise InvalidParameterError, ::RailsParam::ErrorMessages::CannotBeLessThanMessage.new(param_name, value).to_s unless param.nil? || value <= param + raise_param_should_be_less_than(param, param_name, value, options[:message]) when :max - raise InvalidParameterError, ::RailsParam::ErrorMessages::CannotBeGreaterThanMessage.new(param_name, value).to_s unless param.nil? || value >= param + raise_param_should_be_greater_than(param, param_name, value, options[:message]) when :min_length - raise InvalidParameterError, ::RailsParam::ErrorMessages::MustHaveLengthLessThanMessage.new(param_name, value).to_s unless param.nil? || value <= param.length + raise_param_length_should_be_less_than(param, param_name, value, options[:message]) when :max_length - raise InvalidParameterError, ::RailsParam::ErrorMessages::MustHaveLengthGreaterThanMessage.new(param_name, value).to_s unless param.nil? || value >= param.length + raise_param_length_should_be_greater_than(param, param_name, value, options[:message]) end end end + def raise_param_length_should_be_greater_than(param, param_name, value, custom_message_class = nil) + return if param.nil? || value >= param.length + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::MustHaveLengthGreaterThanMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_length_should_be_less_than(param, param_name, value, custom_message_class = nil) + return if param.nil? || value <= param.length + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::MustHaveLengthLessThanMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_should_be_greater_than(param, param_name, value, custom_message_class = nil) + return if param.nil? || value >= param + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::CannotBeGreaterThanMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_should_be_less_than(param, param_name, value, custom_message_class = nil) + return if param.nil? || value <= param + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::CannotBeLessThanMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_should_be_within_range(param, param_name, value, custom_message_class = nil) + return if param.nil? || case value + when Range + value.include?(param) + else + Array(value).include?(param) + end + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::MustBeWithinMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_invalid_param(message_class, param_name, value) + raise InvalidParameterError, message_class.new(param_name, value).to_s + end + + def raise_param_must_be_equal(param, param_name, value, custom_message_class = nil) + return if param === value + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::MustBeEqualMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_should_match_regex(param, param_name, value, custom_message_class = nil) + return if param =~ value + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::MustMatchRegexMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_should_be_string(param, param_name, custom_message_class = nil) + return if param.kind_of?(String) + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::MustBeAStringMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_blank_param(param, param_name, value, custom_message_class = nil) + return unless !value && case param + when String + !(/\S/ === param) + when Array, Hash + param.empty? + else + param.nil? + end + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::IsBlankMessage) + raise_invalid_param(message_class, param_name, value) + end + + def raise_param_required(param, param_name, value, custom_message_class = nil) + return unless value && param.nil? + + message_class = chose_message_class(custom_message_class,::RailsParam::ErrorMessages::IsRequiredMessage) + raise_invalid_param(message_class, param_name, value) + end + + def chose_message_class(custom_message_class, app_message_class) + custom_message_class.nil? ? app_message_class : custom_message_class + end end end diff --git a/spec/rails_param/param_spec.rb b/spec/rails_param/param_spec.rb index f1d4c3a..a6e31ca 100644 --- a/spec/rails_param/param_spec.rb +++ b/spec/rails_param/param_spec.rb @@ -13,6 +13,14 @@ require 'rails_param/param' require 'action_controller' + +class CustomMessage < RailsParam::ErrorMessages::BaseMessage + def to_s + "Parameter #{param_name} should display custom message" + end +end + + class MyController < ActionController::Base include RailsParam::Param @@ -348,6 +356,13 @@ def params; allow(controller).to receive(:params).and_return({}) expect { controller.param! :price, Integer, required: true }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price is required") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({}) + expect { + controller.param! :price, Integer, required: true, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end describe "blank parameter" do @@ -360,6 +375,13 @@ def params; allow(controller).to receive(:params).and_return({"price" => ""}) expect { controller.param! :price, String, blank: false }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price cannot be blank") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "price" => "" }) + expect { + controller.param! :price, String, blank: false, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end describe "format parameter" do @@ -372,6 +394,13 @@ def params; allow(controller).to receive(:params).and_return({"price" => "50"}) expect { controller.param! :price, String, format: /[0-9]+\$/ }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price must match format #{/[0-9]+\$/}") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "price" => "50" }) + expect { + controller.param! :price, String, format: /[0-9]+\$/, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end describe "is parameter" do @@ -384,6 +413,13 @@ def params; allow(controller).to receive(:params).and_return({"price" => "51"}) expect { controller.param! :price, String, is: "50" }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price must be 50") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "price" => "51" }) + expect { + controller.param! :price, String, is: "50", message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end describe "min parameter" do @@ -396,6 +432,13 @@ def params; allow(controller).to receive(:params).and_return({"price" => "50"}) expect { controller.param! :price, Integer, min: 51 }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price cannot be less than 51") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "price" => "50" }) + expect { + controller.param! :price, Integer, min: 51, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end describe "max parameter" do @@ -408,6 +451,13 @@ def params; allow(controller).to receive(:params).and_return({"price" => "50"}) expect { controller.param! :price, Integer, max: 49 }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price cannot be greater than 49") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "price" => "50" }) + expect { + controller.param! :price, Integer, max: 49, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end describe "min_length parameter" do @@ -420,6 +470,13 @@ def params; allow(controller).to receive(:params).and_return({"word" => "foo"}) expect { controller.param! :word, String, min_length: 4 }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter word cannot have length less than 4") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "word" => "foo" }) + expect { + controller.param! :word, String, min_length: 4, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter word should display custom message') + end end describe "max_length parameter" do @@ -432,6 +489,13 @@ def params; allow(controller).to receive(:params).and_return({"word" => "foo"}) expect { controller.param! :word, String, max_length: 2 }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter word cannot have length greater than 2") end + + it "raises with custom param" do + allow(controller).to receive(:params).and_return({ "word" => "foo" }) + expect { + controller.param! :word, String, max_length: 2, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter word should display custom message') + end end describe "in, within, range parameters" do @@ -445,6 +509,12 @@ def params; it "raises outside the range" do expect { controller.param! :price, Integer, in: 51..100 }.to raise_error(RailsParam::Param::InvalidParameterError, "Parameter price must be within 51..100") end + + it "raises with custom param" do + expect { + controller.param! :price, Integer, in: 51..100, message: CustomMessage + }.to raise_error(RailsParam::Param::InvalidParameterError, 'Parameter price should display custom message') + end end end end From 4a134b75b9be9ab7bb550ac314bd646fc175eec8 Mon Sep 17 00:00:00 2001 From: Cosmin Barbu Date: Wed, 4 Oct 2017 16:21:43 +0300 Subject: [PATCH 3/3] add require for error messages --- lib/rails_param/param.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/rails_param/param.rb b/lib/rails_param/param.rb index 0f05298..e0e1a11 100644 --- a/lib/rails_param/param.rb +++ b/lib/rails_param/param.rb @@ -1,3 +1,14 @@ +require_relative './error_messages/base_message' +require_relative './error_messages/cannot_be_greater_than_message' +require_relative './error_messages/cannot_be_less_than_message' +require_relative './error_messages/is_blank_message' +require_relative './error_messages/is_required_message' +require_relative './error_messages/must_be_a_string_message' +require_relative './error_messages/must_be_equal_message' +require_relative './error_messages/must_be_within_message' +require_relative './error_messages/must_have_length_greater_than_message' +require_relative './error_messages/must_have_length_less_than_message' +require_relative './error_messages/must_match_regex_message' module RailsParam module Param