class AFCSalesforce::Tools::Validation::Rule::Matches
Matches
rule
Attributes
obj[W]
Public Class Methods
new(matcher_field)
click to toggle source
This class should take the field to match with in the constructor:
rule = Validation::Rule::Matches(:password) rule.obj = OpenStruct.new(:password => 'foo') rule.valid_value?('foo')
# File lib/afc_salesforce/tools/validation/rule/matches.rb, line 14 def initialize(matcher_field) @matcher_field = matcher_field end
Public Instance Methods
error(value)
click to toggle source
# File lib/afc_salesforce/tools/validation/rule/matches.rb, line 23 def error(value) results = {} results[:expected] = value results[:got] = @obj.send(@matcher_field) results end
error_key()
click to toggle source
The error key for this rule
# File lib/afc_salesforce/tools/validation/rule/matches.rb, line 19 def error_key :matches end
params()
click to toggle source
Params is the matcher_field given in the constructor
# File lib/afc_salesforce/tools/validation/rule/matches.rb, line 31 def params @matcher_field end
valid_value?(value)
click to toggle source
Determines if value matches the field given in the constructor
# File lib/afc_salesforce/tools/validation/rule/matches.rb, line 36 def valid_value?(value) matcher_value = @obj.send(@matcher_field) matcher_value == value end