Sha256: eb477ae9bef5d771c528390cc3db00f1af3a99449928c39dc6e98d3470d3477a
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module Kind module Validator DEFAULT_STRATEGIES = ::Set.new(%w[instance_of kind_of]).freeze class InvalidDefinition < ArgumentError OPTIONS = 'Options to define one: :of, :is, :respond_to, :instance_of, :array_of or :array_with'.freeze def initialize(attribute) super "invalid type definition for :#{attribute} attribute. #{OPTIONS}" end private_constant :OPTIONS end class InvalidDefaultStrategy < ArgumentError OPTIONS = DEFAULT_STRATEGIES.map { |option| ":#{option}" }.join(', ') def initialize(option) super "#{option.inspect} is an invalid option. Please use one of these: #{OPTIONS}" end private_constant :OPTIONS end def self.default_strategy @default_strategy ||= :kind_of end def self.default_strategy=(option) if DEFAULT_STRATEGIES.member?(String(option)) @default_strategy = option.to_sym else raise InvalidDefaultStrategy.new(option) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kind-5.0.0 | lib/kind/validator.rb |
kind-4.1.0 | lib/kind/validator.rb |
kind-4.0.0 | lib/kind/validator.rb |