Class: Cure::Validator::CustomRule

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/cure/validator/base_rule.rb

Instance Method Summary collapse

Methods inherited from BaseRule

#initialize

Constructor Details

This class inherits a constructor from Cure::Validator::BaseRule

Instance Method Details

#custom_procObject



73
74
75
# File 'lib/cure/validator/base_rule.rb', line 73

def custom_proc
  @options.fetch(:proc, proc { |_x| false })
end

#process(value) ⇒ Object



63
64
65
66
67
# File 'lib/cure/validator/base_rule.rb', line 63

def process(value)
  return true if value.nil?

  custom_proc.call(value)
end

#to_sObject



69
70
71
# File 'lib/cure/validator/base_rule.rb', line 69

def to_s
  "Custom"
end