mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Throwing error in PHONE_FORMAT when value is not a string
Summary: Adding type check in the PHONE_FORMAT function. Default conversion to string doesn't work well for floats. Test Plan: Updated Reviewers: dsagal Reviewed By: dsagal Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3701
This commit is contained in:
parent
5c67e12aa5
commit
044d7a1e5c
@ -336,9 +336,19 @@ def PHONE_FORMAT(value, country=None, format=None): # pylint: disable=redefined
|
||||
u'tel:+33-2-34-56-78-90'
|
||||
>>> PHONE_FORMAT("tel:+1-234-567-8901", country="US", format="*")
|
||||
u'+12345678901'
|
||||
>>> PHONE_FORMAT(33234567890)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: Phone number must be a text value. \
|
||||
If formatting a value from a Numeric column, convert that column to Text first.
|
||||
"""
|
||||
if not value:
|
||||
return value
|
||||
|
||||
if not isinstance(value, six.string_types):
|
||||
raise TypeError("Phone number must be a text value. " +
|
||||
"If formatting a value from a Numeric column, convert that column to Text first.")
|
||||
|
||||
if format is None and country in output_formats:
|
||||
format = country
|
||||
country = None
|
||||
|
Loading…
Reference in New Issue
Block a user