There are several quick hacks, parsing as normal (not stable), and performing small checks on the input (for example, when analyzing a non-negative number, check that it does not have a “-” character).
The ultimate reliability check is converting an integer to text and checking that the input text and output text match. When working in the text version, you can relax things, for example, take leading 0s or spaces.
source share