Add "params" as parameter and define this function outside of #validate.
There is no need to do it again and again...