Closed wnagrodzki closed 5 years ago
Source of inspiration Related: Data you can trust. WWDC 2018 Check is it is possible to use RawRepresentable protocol here.
@pwetrifork @moskacz What do you think?
I'm ok with this as long as there is an actual purpose, e.g. in the example above I would only introduce a new type if the app actually validated the emails. Another related idea would be to start with a typealias and refactor later, for example when validation is first introduced. Typealiasing would make refactoring much easier in such scenario.
I'm ok with new type if there is some benefit gained (as @pwetrifork mentioned - need for validation is a good reason for introducing new type). At the same time I'm not a big fan of typealiases. Every time I see a method that takes typealias as a parameter I need to think what it really is.
@pwetrifork @Moskacz Thanks, very good point. I edited the text to reflect that
It is too general provided that application expects email to have certain format.
If you have an idea how to rephrase the section better, let me know. Otherwise I will include like it is into the guidelines soon.
It is common to misuse primitive type like in the function below. Any string can be passed as the argument. It is too general provided that application expects email to have certain format.
Define a new type to make the API more strict, provide validation and convenience methods/properties if needed.