Class: ValidatedObject::Base::TypeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ValidatedObject::Base::TypeValidator
- Extended by:
- T::Sig
- Defined in:
- lib/validated_object.rb
Overview
A custom validator which ensures an object is an instance of a class or a subclass. It supports a pseudo-boolean class for convenient validation. (Ruby doesn’t have a built-in Boolean.)
Automatically used in a type validation:
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/validated_object.rb', line 116 def validate_each(record, attribute, value) = T.let(, SymbolHash) expected_class = [:with] return if pseudo_boolean?(expected_class, value) || expected_class?(expected_class, value) save_error(record, attribute, value, ) end |