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



18
19
20
# File 'lib/sequent/core/helpers/string_validator.rb', line 18

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