For your particular function, when $x > 5$ and $x$ is even, $f(x)$ is generally not well-defined, which means that $x$ maps to multiple things. This can be resolved if $g(x) = h(x)$ when $x>5$ and $x$ is even. So if you mean "valid" as in well-defined, it depends whether or not the previous condition is met.
A function must be well-defined (as per definition of a function), but there are examples of mappings which aren't functions. For instance, consider the $n$-th root of a real number $a$. For $n>1$ and $a \neq 0$, the amount of numbers that satisfy $x^n = a$ is more than one. Hence, we mathematicians avoid this problem by only using a specific "branch cut". The most common example is the principle square root, or $\sqrt{\hspace{1em}}$, which is well-defined and hence, a function.
For your particular function, when $x > 5$ and $x$ is even, $f(x)$ is generally not well-defined, which means that $x$ maps to multiple things. This can be resolved if $g(x) = h(x)$ when $x>5$ and $x$ is even. So if you mean "valid" as in well-defined, it depends whether or not the previous condition is met.
A function must be well-defined (as per definition of a function), but there are examples of mappings which aren't functions. For instance, consider the $n$-th root of a real number $a$. For $n>1$ and $a \neq 0$, the amount of numbers that satisfy $x^n = a$ is more than one. Hence, we mathematicians avoid this problem by only using a specific "branch cut". The most common example is the principle square root, or $\sqrt{\hspace{1em}}$, which is well-defined and hence, a function.