# Vex validate w anon. function: cannot inject attribute @vex\_validations into function/macro because cannot escape #Function

**URL:** <https://forum.elixirforum.com/t/vex-validate-w-anon-function-cannot-inject-attribute-vex-validations-into-function-macro-because-cannot-escape-function/46256>\
**Category:** Questions\
**Tags:** anonymous-functions, vex\
**Created:** [February 24, 2022, 8:31am UTC](https://forum.elixirforum.com/t/vex-validate-w-anon-function-cannot-inject-attribute-vex-validations-into-function-macro-because-cannot-escape-function/46256 "2022-02-24T08:31:55Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![chemist](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/c/d9b06d/32.png) [@chemist](https://forum.elixirforum.com/u/chemist)\
**Post date:** [February 24, 2022, 9:49am UTC](https://forum.elixirforum.com/t/vex-validate-w-anon-function-cannot-inject-attribute-vex-validations-into-function-macro-because-cannot-escape-function/46256/9 "2022-02-24T09:49:05Z")

</div>

```elixir
  validates(:withdrawal, presence: [message: "expected"], 
  by: [function: &Test.test(&1, Map.get(&2, :funds_balance)), 
  message: "invalid withdrawal."])

```

`Map.get(&2, :funds_balance)` will evaluate to the value held in `funds_balance` and `@enforce_keys` guarantee a non nil value. And i have tested it with a non-nil value.

The function `Test.test` has an arity of 2 and accepts two values `&1: withdrawal` (which is being evaluated) and **the outcome of evaluating `Map.get`** `&2: funds balance` resulting in an evaluation which is either false or true

So as a result, the function for the validator above will return true or false.

What I believe is the anon function utilizing the Vex.validator does not seem to like having a nested function using a capture operator. So im checking my understanding.

---

_[View the full topic](https://forum.elixirforum.com/t/vex-validate-w-anon-function-cannot-inject-attribute-vex-validations-into-function-macro-because-cannot-escape-function/46256)._
