Class: Validation::Rule::Phone
- Inherits:
-
Object
- Object
- Validation::Rule::Phone
- Defined in:
- lib/validation/rule/phone.rb
Overview
Phone rule
Instance Method Summary collapse
- #error_key ⇒ Object
-
#initialize(params = {:format => :america}) ⇒ Phone
constructor
params can be any of the following:.
-
#params ⇒ Object
returns the params given in the constructor.
-
#valid_value?(value) ⇒ Boolean
determines if value is valid according to the constructor params.
Constructor Details
#initialize(params = {:format => :america}) ⇒ Phone
params can be any of the following:
- :format - the phone number format
Example:
{:format => :america}
12 13 14 |
# File 'lib/validation/rule/phone.rb', line 12 def initialize(params = {:format => :america}) @params = params end |
Instance Method Details
#error_key ⇒ Object
26 27 28 |
# File 'lib/validation/rule/phone.rb', line 26 def error_key :phone end |
#params ⇒ Object
returns the params given in the constructor
17 18 19 |
# File 'lib/validation/rule/phone.rb', line 17 def params @params end |
#valid_value?(value) ⇒ Boolean
determines if value is valid according to the constructor params
22 23 24 |
# File 'lib/validation/rule/phone.rb', line 22 def valid_value?(value) send(@params[:format], value) end |