Put the typeof check inside the `isValidValue` function.