Sha256: b2c1c595c89e727e009c6fe1e007f4587ede817d5804225aab6598e3b71251fa

Contents?: true

Size: 637 Bytes

Versions: 48

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  module Validations
    extend ActiveSupport::Concern

    attr_accessor :error

    def validate
      @error = nil

      self.class.validations.each do |validation|
        @error = validation[:options][:error] unless send("validate_#{validation[:attribute]}")
        break if @error
      end
    end

    def valid?
      validate
      @error.nil?
    end

    module ClassMethods
      def validate(attribute, options = {})
        validations << { attribute: attribute, options: options }
      end

      def validations
        @validations ||= []
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
doorkeeper-5.8.1 lib/doorkeeper/validations.rb
doorkeeper-5.8.0 lib/doorkeeper/validations.rb
doorkeeper-5.7.1 lib/doorkeeper/validations.rb
doorkeeper-5.7.0 lib/doorkeeper/validations.rb
doorkeeper-5.6.9 lib/doorkeeper/validations.rb
doorkeeper-5.6.8 lib/doorkeeper/validations.rb
doorkeeper-5.6.7 lib/doorkeeper/validations.rb
doorkeeper-5.6.6 lib/doorkeeper/validations.rb
doorkeeper-5.6.5 lib/doorkeeper/validations.rb
doorkeeper-5.6.4 lib/doorkeeper/validations.rb
doorkeeper-5.6.3 lib/doorkeeper/validations.rb
doorkeeper-5.6.2 lib/doorkeeper/validations.rb
doorkeeper-5.6.1 lib/doorkeeper/validations.rb
doorkeeper-5.6.0 lib/doorkeeper/validations.rb
doorkeeper-5.6.0.rc2 lib/doorkeeper/validations.rb
doorkeeper-5.6.0.rc1 lib/doorkeeper/validations.rb
doorkeeper-5.5.4 lib/doorkeeper/validations.rb
doorkeeper-5.5.3 lib/doorkeeper/validations.rb
doorkeeper-5.5.2 lib/doorkeeper/validations.rb
doorkeeper-5.5.1 lib/doorkeeper/validations.rb