How to constrict serial input to only 3 numbers?

But 0 is a one digit number and 42 is a two digit number.

Perhaps 000 and 042 would be sent. Just the character/number thing.