I would validate when the text box changes and report the error with an in-line non-blocking error. If you have partial input which is inherently invalid then you can filter that out, but I wouldn't alter input which is currently invalid but which could
become valid either by further typing or by changing a different option.
I prefer leaving invalid input for the user to change rather than forcing it to a default or blank value: as a user it frustrates me when I partially enter a value, switch away to confirm that what I have is correct, and then come back and my edits have
been lost.
If the user exits the setting pane with an invalid setting I'd cancel the change and leave the setting where it had been previously.
See the Errors section in the
Laying out your UI docs for an overview of best practices for reporting errors.
--Rob