Fix check type before checking if value is valid