Class: Sequent::Core::Helpers::StringValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/sequent/core/helpers/string_validator.rb

Overview

Validates String’s Automatically included when using a

attrs value: String

Basically all ruby String are valid Strings.

For now we do fail when value is not a String or contains a any chars defined in ValueValidators::INVALID_CHARS

Instance Method Summary collapse

Instance Method Details

#validate_each(subject, attribute, value) ⇒ Object



20
21
22
23
24
25
# File 'lib/sequent/core/helpers/string_validator.rb', line 20

def validate_each(subject, attribute, value)
  unless Sequent::Core::Helpers::ValueValidators.for(String).valid_value?(value)
    subject.errors.add attribute,
                       :invalid_string
  end
end