Class: ProMotion::RegexValidator
- Defined in:
- lib/ProMotion/XLForm/validators/regex_validator.rb
Instance Attribute Summary collapse
-
#regex ⇒ Object
Returns the value of attribute regex.
Attributes inherited from Validator
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, regex) ⇒ RegexValidator
constructor
A new instance of RegexValidator.
- #valid?(row) ⇒ Boolean
Methods inherited from Validator
Constructor Details
#initialize(message, regex) ⇒ RegexValidator
Returns a new instance of RegexValidator.
5 6 7 8 |
# File 'lib/ProMotion/XLForm/validators/regex_validator.rb', line 5 def initialize(, regex) @message = @regex = regex end |
Instance Attribute Details
#regex ⇒ Object
Returns the value of attribute regex.
3 4 5 |
# File 'lib/ProMotion/XLForm/validators/regex_validator.rb', line 3 def regex @regex end |
Class Method Details
.validator(message, regex) ⇒ Object
16 17 18 |
# File 'lib/ProMotion/XLForm/validators/regex_validator.rb', line 16 def self.validator(, regex) ProMotion::RegexValidator.new(, regex) end |
Instance Method Details
#valid?(row) ⇒ Boolean
10 11 12 13 14 |
# File 'lib/ProMotion/XLForm/validators/regex_validator.rb', line 10 def valid?(row) return nil if row.nil? || row.value.nil? || !row.value.is_a?(String) !@regex.match(row.value).nil? end |