class Mixture::Validate::Match
Checks that a value matches.
Public Instance Methods
validate(record, attribute, value)
click to toggle source
Performs the validation.
@param (see Base#validate
) @return (see Base#validate
) @raise [ValidationError] If {#match?} returns false.
Calls superclass method
Mixture::Validate::Base#validate
# File lib/mixture/validate/match.rb, line 15 def validate(record, attribute, value) super error("Value does not match") unless match? end
Private Instance Methods
match?()
click to toggle source
Checks if the value matches the given matcher. It uses the `=~` operator. If it fails (i.e. raises an error), it returns false.
@return [Boolean]
# File lib/mixture/validate/match.rb, line 27 def match? @value =~ @options rescue StandardError false end