Class: Mixture::Validate::Match

Inherits:
Base
  • Object
show all
Defined in:
lib/mixture/validate/match.rb

Overview

Checks that a value matches.

Instance Method Summary collapse

Methods inherited from Base

#error, #initialize

Constructor Details

This class inherits a constructor from Mixture::Validate::Base

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/mixture/validate/match.rb', line 12

def match?
  @value =~ @options
end

#validate(record, attribute, value) ⇒ Object



7
8
9
10
# File 'lib/mixture/validate/match.rb', line 7

def validate(record, attribute, value)
  super
  error("Value does not match") unless match?
end