Sha256: 27813fe850ed8a7f8643cef49b3bbb321c71383324c3190c98674b5017eaed46

Contents?: true

Size: 743 Bytes

Versions: 3

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true
# author: Vadim Shaveiko <@vshaveyko>
require_relative 'validate_ary_object'
require_relative 'validate_enum'
require_relative 'validate_type'

class RailsApiDoc::Config::Validator

  class << self

    attr_accessor :checkers

    def add_checker(klass)
      return if checkers.detect { |c| c.is_a?(klass) }

      checkers << klass.new
    end

    def remove_checker(klass)
      checkers.delete_if { |c| c.is_a?(klass) }
    end

    def valid_param?(controller_param, api_param_data)
      checkers.all? do |checker|
        checker.valid?(controller_param, api_param_data)
      end
    end

  end

  self.checkers = [RailsApiDoc::Config::ValidateEnum.new, RailsApiDoc::Config::ValidateAryObject.new]

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_api_documentation-0.2.2 lib/rails_api_doc/config/validator.rb
rails_api_documentation-0.2.1 lib/rails_api_doc/config/validator.rb
rails_api_documentation-0.2.0 lib/rails_api_doc/config/validator.rb