otp-generator icon indicating copy to clipboard operation
otp-generator copied to clipboard

Only Digits OTP Length

Open kandarpkakkad opened this issue 2 years ago • 1 comments

When I get a string of 6 digits and 1st character is 0, the actual number becomes 5 digits. This should not happen. Can we add a check that the 1st character is not 0 in case of only digits OTP?

kandarpkakkad avatar Sep 02 '22 19:09 kandarpkakkad

0 at start is also valid OTP. Let me think if we can add option for same.

Maheshkumar-Kakade avatar Sep 03 '22 14:09 Maheshkumar-Kakade

I started using this package specifically to avoid this issue... @kandarpkakkad or @Maheshkumar-Kakade - I dunno, has this issue been resolved? or is it still open?

Bankole2000 avatar Jan 15 '23 23:01 Bankole2000

It is not fixed yet. I will fix it by 20th Jan.

Maheshkumar-Kakade avatar Jan 15 '23 23:01 Maheshkumar-Kakade

Like @Maheshkumar-Kakade pointed out, 0 is a valid start for an OTP. If your application removes the leading zeroes, you should be storing it as string and not a number. This should really be behind an optional configuration flag, and not enabled by default.

theseyan avatar Jan 13 '24 08:01 theseyan