Class: PoroValidator::Validators::FormatValidator
- Defined in:
- lib/poro_validator/validators/format_validator.rb
Overview
Instance Attribute Summary
Attributes inherited from BaseClass
Instance Method Summary collapse
Methods inherited from BaseClass
#__validate__, #context, #errors, #initialize, #nested?, #options, #value
Constructor Details
This class inherits a constructor from PoroValidator::Validators::BaseClass
Instance Method Details
#validate(attribute, value, options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/poro_validator/validators/format_validator.rb', line 4 def validate(attribute, value, ) return if value.nil? pattern = .fetch(:with) = .fetch(:message, :format) unless value.to_s =~ pattern errors.add(attribute, , pattern) end end |