Pretty sure it is debug code now.
I searched for other places where the string validity check function is called.
It's called in three places. One of those seems to be unused, and all incorporate parts of the checks detailed in the OP.
The unused occurrence and first used occurrence are in Battle Tower code,
sanitising Battle Tower Pokémon after they are read. (The unused occurrence seems to have just been dummied out, as it is directly after the used code ends.)
This code sanitises Pokémon nicknames, replaces any OT name with bad characters with "CHRIS" (only one terminator this time), makes sure all nicknames and the OT name are terminated, and
sanitises invalid moves in the same way as detailed in the OP (except here, move
$00 is never considered invalid).
The unused half of this function replaces invalid Pokémon species (
$FD being considered invalid) with Smeargle (
$EB). Instead of a simple greater-than-or-equal check, it checks for equality against each invalid species value in turn. Pokémon levels are also checked, but the maximum level instead of being hardcoded is taken from SRAM at
5:B2FB.
The last occurrence is inside
mobile-related code. Every single string (nickname, OT, mail, mail author) is checked for invalid bytes and termination (where the terminator is
$4E for some reason) within the correct length, by bankswitched calls. If one of these checks fails, the offending string is replaced with a default string by a bankswitched call.
Here's a list of default strings used:
OT name, mail author: "クりス"
Chris followed by two terminators
Pokémon nickname: "?????"
unterminated(!!!)
Mail text: "こんにちは"
"Konnichiwa" Hello followed by one terminator
The default strings are terminated by
$50 as usual.
After checking the strings, an "item" at
$C60E is checked, if it's
$FF it gets replaced by
$00. Finally, the exact same level checks as in the OP are performed.