Sha256: 106a8045d3c44c91744a7cf554c91a801abf29e00c342c8934c6c383824a35cf

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Strict
  module Dsl
    module Validatable
      # rubocop:disable Naming/MethodName

      def AllOf(*subvalidators) = ::Strict::Validators::AllOf.new(*subvalidators)
      def AnyOf(*subvalidators) = ::Strict::Validators::AnyOf.new(*subvalidators)
      def Anything = ::Strict::Validators::Anything.instance
      def ArrayOf(element_validator) = ::Strict::Validators::ArrayOf.new(element_validator)
      def Boolean = ::Strict::Validators::Boolean.instance

      def HashOf(key_validator_to_value_validator)
        if key_validator_to_value_validator.size != 1
          raise ArgumentError, "HashOf's usage is: HashOf(KeyValidator => ValueValidator)"
        end

        key_validator, value_validator = key_validator_to_value_validator.first
        ::Strict::Validators::HashOf.new(key_validator, value_validator)
      end

      def RangeOf(element_validator) = ::Strict::Validators::RangeOf.new(element_validator)

      # rubocop:enable Naming/MethodName
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
strict-1.5.0 lib/strict/dsl/validatable.rb
strict-1.4.0 lib/strict/dsl/validatable.rb
strict-1.3.1 lib/strict/dsl/validatable.rb
strict-1.3.0 lib/strict/dsl/validatable.rb
strict-1.2.0 lib/strict/dsl/validatable.rb
strict-1.1.0 lib/strict/dsl/validatable.rb
strict-1.0.0 lib/strict/dsl/validatable.rb