TRIM or UNION always not Valid ! is it good for use in script?

Sometime operate solid tool, we get unvalid. is it good for use in script. or others way to check it’s valid.
Always not valid