Class: Rulix::Validators::FormatValidator
- Inherits:
-
Object
- Object
- Rulix::Validators::FormatValidator
- Defined in:
- lib/rulix/validators/format_validator.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
- #call(string) ⇒ Object
-
#initialize(options = nil) ⇒ FormatValidator
constructor
A new instance of FormatValidator.
- #to_proc ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ FormatValidator
Returns a new instance of FormatValidator.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rulix/validators/format_validator.rb', line 6 def initialize = nil case when Regexp self.pattern = when Hash self.pattern = [:pattern] self. = [:message] else ||= {} end self. ||= 'does not match format' end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/rulix/validators/format_validator.rb', line 4 def @message end |
#pattern ⇒ Object
Returns the value of attribute pattern.
4 5 6 |
# File 'lib/rulix/validators/format_validator.rb', line 4 def pattern @pattern end |
Instance Method Details
#call(string) ⇒ Object
20 21 22 |
# File 'lib/rulix/validators/format_validator.rb', line 20 def call string (string && pattern === string) || [false, ] end |
#to_proc ⇒ Object
24 25 26 |
# File 'lib/rulix/validators/format_validator.rb', line 24 def to_proc method(:call) end |