Class: Rulix::Validators::StringValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/rulix/validators/string_validator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_procObject



4
5
6
# File 'lib/rulix/validators/string_validator.rb', line 4

def self.to_proc
  new.method(:call)
end

Instance Method Details

#call(value) ⇒ Object



8
9
10
11
12
# File 'lib/rulix/validators/string_validator.rb', line 8

def call value
  return [false, error_message] unless value

  String === value || [false, error_message]
end

#error_messageObject



14
15
16
# File 'lib/rulix/validators/string_validator.rb', line 14

def error_message
  "is not a string"
end