Input fewer characters-mask?

I'd like to create a maskformatter that let's me decide on a mask like normal (i.e. "###-####" for phone numbers), but I'd like to be able to input fewer characters (digits, in this case), but Not more than the mask allows. Is there a way to do this?

So, if my mask is "###", I want to be able to input both 213, Or, 12 (without adding any invisible ' ' or stuff like that...).

Another solution that might work in my case, I realised writing this post, would be to restrict input characters to integers (basically the same thing, but without an upper boundary). Is that possible?