diff options
Diffstat (limited to 'lib/saml/kit/concerns/validatable.rb')
| -rw-r--r-- | lib/saml/kit/concerns/validatable.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/saml/kit/concerns/validatable.rb b/lib/saml/kit/concerns/validatable.rb new file mode 100644 index 0000000..26e6706 --- /dev/null +++ b/lib/saml/kit/concerns/validatable.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Saml + module Kit + # This module is responsible for + # providing an adapter to the ActiveModel::Validations + # module. + module Validatable + extend ActiveSupport::Concern + include ActiveModel::Validations + + def each_error + if Gem::Requirement.new('>= 6.1').satisfied_by?(ActiveModel.version) + errors.each do |error| + yield error.attribute, error.message + end + else + errors.each do |attribute, message| + yield attribute, message + end + end + end + end + end +end |
