| Class | Grape::Validations::Types::VariantCollectionCoercer |
| In: |
lib/grape/validations/types/variant_collection_coercer.rb
|
| Parent: | Virtus::Attribute |
This class wraps {MultipleTypeCoercer}, for use with collections that allow members of more than one type.
Construct a new coercer that will attempt to coerce a list of values such that all members are of one of the given types. The container may also optionally be coerced to a Set. An arbitrary coercion method may be supplied, which will be passed the entire collection as a parameter and should return a new collection, or may return the same one if no coercion was required.
@param types [Array<Class>,Set<Class>] list of allowed types,
also specifying the container type
@param method [call,parse] method by which values should be coerced
Coerce the given value.
@param value [Array<String>] collection of values to be coerced @return [Array<Object>,Set<Object>,InvalidValue]
the coerced result, or an instance
of {InvalidValue} if the value could not be coerced.
Assert that the value has been coerced successfully.
@param value [Object] a coerced result returned from {coerce} @return [true,false] whether or not the coerced value
satisfies type requirements.