Class: Subvalid::Validators::FormatValidator
- Inherits:
-
Object
- Object
- Subvalid::Validators::FormatValidator
- Defined in:
- lib/subvalid/validators/format_validator.rb
Class Method Summary collapse
Class Method Details
.validate(object, validation_result = ValidationResult.new, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/subvalid/validators/format_validator.rb', line 4 def self.validate(object, validation_result=ValidationResult.new, *args) = args.to_h rescue args with = nil = "is invalid" case when Regexp with = when Hash with = .fetch(:with) = [:message] || else raise "don't know what to do with #{}" end validation_result.add_error() unless with.match(object) end |