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
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/validated_object.rb', line 108 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 |