keepworks/KWVerificationCodeView

getVerificationCode method returns string with whitespace.

Closed this issue · 4 comments

getVerificationCode return string with a whitespace.

I was trying to get the count of the string returned by getVerificationCode(). It alwasy shows 1 extra count since it has a whitespace

@abhijithpp I tried to reproduce the issue but couldn't. Tried via IB & programatically. Can you give steps to reproduce this?

In the mean time you can trim the whitespaces using the following code:

code.trimmingCharacters(in: CharacterSet.whitespaces)

Input - 123
The method returns "123 "

PFA screenshot.

Screen Shot 2019-06-06 at 08 36 40

@abhijithpp if you want only 3 digits you need to set otpTextFieldView.digits = 3

If you are trying to validate the code using the code count, you can use the method otpTextFieldView.hasValidCode() which returns true if all the digits are filled, false if there are empty fields

Check our example project for clear implementation regarding the same.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.