Sha256: d0639cbc40e9ab37a5326da2bd5379c071c4db63f0c6fdf1b8e6ed3e34e4373e

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

# frozen_string_literal: true

module Mockolate::Validators
  class << self
    def check_value_given?(obj)
      return if _check_has_default_value?(obj) || _check_both_given?(obj)
      raise Mockolate::Errors::MissingValueError, 'Default value or all Faker options should be given'
    end

    def check_faker(obj)

    end

    private
    def _check_has_default_value?(obj)
      !!obj[:value]
    end

    def _check_has_faker_key?(obj)
      return !!obj[:key] 
    end

    def _check_has_faker_module?(obj)
      return !!obj[:fake_from]
    end

    def _check_both_given?(obj)
      _check_has_faker_key?(obj) &&  _check_has_faker_module?(obj)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mockolate-0.1.0 lib/mockolate/validators.rb