Conditional If Statement based on length

Looking thru the Docs i don’t see a a basic IF function
I am trying to evaluate the length of a field and if it is 10 i want to apply special format.

Something like
if LENGTH(v.number) = 10 then
“(” || SUBSTR(v.number, 0,3) || ") " || SUBSTR(v.number, 3,3) || “-” || SUBSTR(v.number, 6,4)
else
v.number

CASE WHEN LENGTH(v. number ) = 10 THEN
“(” || SUBSTR(v. number , 0,3) || ") " || SUBSTR(v. number , 3,3) || “-” || SUBSTR(v. number , 6,4)
else
v. number END

Thanks that works, but how can i make this work if this is possibly a nbr as the length seems to only work for string and not for numbers. Is there a way to make it work for string or number length ?

TO_STRING() converts string if not possible it returns NULL