Is it better to store telephone numbers in some canonical format or “as entered”?

前端 未结 12 1506
鱼传尺愫
鱼传尺愫 2020-12-11 00:59

Storing a telehone number in some kind of canonical format has several advantages from a programmers point of view, but it might confuse the user, if sudde

12条回答
  •  执念已碎
    2020-12-11 02:02

    Separation of Duties - Content and Rendering

    Store the number in a canonical format and the display format mask.

    Gains:

    • Canonical format for consistency, quality, and ease of analysis
    • Format retained from end-user perspective
    • Format re-usable to display other phone numbers in end-user preferred method
    • Other format masks can be used to display canonical number to other users with a need to see the phone number

    Pains:

    • Parsing the phone number to the canonical format
    • Parsing out the display format mask (not too painful in combination with above bullet)
    • Storing the display format as an end-user preference

提交回复
热议问题