summaryrefslogtreecommitdiff
path: root/lib/saml/kit/concerns/validatable.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2022-03-30 14:58:34 -0600
committermo khan <mo@mokhan.ca>2022-03-30 16:21:56 -0600
commit45f85f64115cf522e43569451f3f4f7977c862c1 (patch)
tree102637e5bf8332a35b4b668bae9b9af51cc1c662 /lib/saml/kit/concerns/validatable.rb
parent6e457e266ddb0e587aaf9b4fb84b292003ba38a9 (diff)
feat: drop ruby 2.5 and 2.6v1.3.0
fix: upgrade to Ruby 2.7+ *args syntax. * https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ fix: resolve deprecation warnings * https://github.com/rails/rails/pull/32313
Diffstat (limited to 'lib/saml/kit/concerns/validatable.rb')
-rw-r--r--lib/saml/kit/concerns/validatable.rb25
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