-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First number of mask(#104) #111
Comments
Hi @margulan97 From you, I need a complete user story, including all the edge cases, regarding the phone numbers ought to be formatted. Right now, I haven't got enough information on what's actually happening in your app. From a cursory view, it feels like you've got to sanitise your data before it appears on the UI layer; thus, overriding the library behaviour would be a design violation. |
for example I have many mask like "+7 [999]" and "55[999]" and etc, when value comes from backend and set value in mask like that and first char in text Is the same as +7 or 5 mask removes first character. |
Okay, does your app serve multiple countries? |
this mask is not for the phone, but for payments. all masks come from the backend and can be pre-filled if the user made such a payment before. |
if let firstMaskNumber = primaryMaskFormat.first(where: { $0.isNumber }), |
Why do you think so? |
I think the mask class should return the correct result, because all the logic with the cursor and text in this class. Maybe I'm wrong idk |
Got it. Here, you've got to apply an architectural design alteration. See, previously, your user had conducted a payment associated with a concrete, formatted number. Thus, you've got two options. {
"number": "123…",
"mask": "+7 [999]…"
} Second option, during the initial payment attach an already formatted number and make sure to use it afterwards: {
"number": "123…",
"formatted_number": "+7 123…"
} |
The Your proposition is to make it aware that the text is actually a number and has some additional info behind it, which is an SRP violation and an abstraction hole. |
AFAIU you receive masks from your backend, and it seems like you are omitting the first number of your value for some reason. Meaning that you use Thus, your system is missing a mandatory part of user information. This part is mandatory because you actually use it for subsequent payments. |
In both cases Expected behavior: Solved: |
Hi @roostique
Are you sure? My apologies, but the library behaviour wasn't implemented like that. For an empty text field with |
Thank you for response |
@roostique thanks for a quick response! You may check out our Sample project with simple text fields for a reference. |
@roostique heya Got any updates? |
@taflanidi hi! i've updated my comment with the solution. |
Whoa. Okay, thank you so much. Sounds like I've got to add some measures to manage this case as well. |
Prerequisites
X
between the brackets on this line if you have done all of the following:input-mask
tag for similar problems.I have previous request #104 about first symbol
can you help me where I can fix that behavior, because I have multiple masks that comes from backend and I need to fill it correctly now I fix it only for phone number case.
open func put(text: String, into field: UITextField, autocomplete putAutocomplete: Bool? = nil, valueWithPrefix: Bool = false) -> InputMask.Result
I add value with prefix parameter that duplicate first char, but I have case where I just put masks from backend I look at apply func in Mask, but I can't find solution
if valueWithPrefix && !updatedText.isEmpty {
if let first = updatedText.first {
let firstCharacter = String(first)
updatedText = firstCharacter + updatedText
}
}
The text was updated successfully, but these errors were encountered: