Skip to content

Commit

Permalink
Improve support for external validation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Oct 29, 2024
1 parent 569e0b8 commit 0a0123e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/action_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
module ActionForm
require_relative 'action_form/engine'

def self.external_validation_methods
@external_validation_methods ||= []
end

def self.rails_buggy?
Rails.gem_version >= Gem::Version.new('7.0.3')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/action_form/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def method_missing(method_sym, *arguments, &block) # rubocop:disable Style/Missi
return if method_sym == :id=

# call validates/validate class methods
if method_sym =~ /^validates?$/ || method_sym == :phony_normalize || method_sym == :libphone_normalize
if method_sym =~ /^validates?$/ || ActionForm.external_validation_methods.include?(method_sym)
class_eval do
public_send(method_sym, *arguments, &block)
end
Expand Down

0 comments on commit 0a0123e

Please sign in to comment.