Closed
Description
I'm trying to combine type coercion with lambda in values validation such as:
requires :type, type: Integer, values: { except: -> { [ 3, 4, 5 ] } } # real implementation would be dynamic call
I get however this error:
/Users/jonathan/code/libs/grape/lib/grape/validations/params_scope.rb:358:in `validate_value_coercion': type: Integer is incompatible with values: {:except=>#<Proc:0x007fa873aabbf8@/Users/jonathan/code/libs/grape/spec/grape/validations/validators/values_spec.rb:150 (lambda)>} (Grape::Exceptions::IncompatibleOptionValues)
Is there a way to use lambda for validation with type coercion? I know we can't validate beforehand that the lambda expression is going to be proper values... but I would still like the parameter passed to be casted into an Integer.