validate email/phone submission format

This commit is contained in:
Pete Matsyburka
2024-01-23 21:46:57 +02:00
parent 8646e17d5a
commit e6052ad0d8
2 changed files with 11 additions and 0 deletions
+8
View File
@@ -59,6 +59,14 @@ module Params
raise_error(message || "#{key} must be a #{type}")
end
def format(params, key, regexp, message: nil)
return if params.blank?
return if params[key].blank?
return if regexp.match?(params[key].to_s)
raise_error(message || "#{key} must follow the #{regexp.source} format")
end
def in_path(params, path = [])
old_path = @current_path