module UltraConfig::Validation
Public Instance Methods
custom(&block)
click to toggle source
# File lib/ultra_config/validation.rb, line 45 def custom(&block) raise ValidationError unless block.call(@intermediate_value) end
match(regexp)
click to toggle source
# File lib/ultra_config/validation.rb, line 37 def match(regexp) raise ValidationError unless regexp.match(@intermediate_value) end
one_of(list)
click to toggle source
# File lib/ultra_config/validation.rb, line 31 def one_of(list) # If comparing against a list of symbols and item is a string, the user probably wants a symbol @intermediate_value = @intermediate_value.to_sym if list.all? { |i| i.is_a?(Symbol) } raise ValidationError unless list.include?(@intermediate_value) end
range(low, high)
click to toggle source
# File lib/ultra_config/validation.rb, line 41 def range(low, high) raise ValidationError unless (@intermediate_value >= low && @intermediate_value <= high) end
type_safety(type)
click to toggle source
# File lib/ultra_config/validation.rb, line 21 def type_safety(type) @type_safety_checked = true return unless type == :strong return if @value.nil? return if @value.is_a?(Boolean) && @intermediate_value.is_a?(Boolean) raise TypeValidationError if @value.class != @intermediate_value.class end