Class: HaveAPI::Client::Validators::Format

Inherits:
HaveAPI::Client::Validator show all
Defined in:
lib/haveapi/client/validators/format.rb

Instance Attribute Summary

Attributes inherited from HaveAPI::Client::Validator

#params, #value

Instance Method Summary collapse

Methods inherited from HaveAPI::Client::Validator

#errors, #initialize, name, register, validate

Constructor Details

This class inherits a constructor from HaveAPI::Client::Validator

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
# File 'lib/haveapi/client/validators/format.rb', line 7

def valid?
  rx = Regexp.new(opts[:rx])

  if opts[:match]
    rx.match(value) ? true : false

  else
    rx.match(value) ? false : true
  end
end