Commits

Andriy Kornatskyy  committed b0362db

Improved error message in case of ValueError on empty input

  • Participants
  • Parent commits b1b2cef

Comments (0)

Files changed (4)

File i18n/en/LC_MESSAGES/validation.po

 msgstr "%H:%M"
 
 #. fallback time input formats: 16:34:52. Use | to separate multiple values.
-#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:20
-#: src/wheezy/validation/format.py:21
+#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:21
 msgid "%H:%M:%S"
 msgstr "%H:%M:%S"
 
 #. default datetime input format: 2008/5/18 16:34
-#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:22
-#: src/wheezy/validation/format.py:23
+#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:23
 msgid "%Y/%m/%d %H:%M"
 msgstr "%Y/%m/%d %H:%M"
 
 #. fallback datetime input formats: 2008/5/18 16:34:52. Use | to separate.
-#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:23
-#: src/wheezy/validation/format.py:26 src/wheezy/validation/format.py:27
+#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:26
+#: src/wheezy/validation/format.py:27
 msgid ""
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:81 src/wheezy/validation/model.py:82
-#: src/wheezy/validation/model.py:91 src/wheezy/validation/model.py:103
-#: src/wheezy/validation/model.py:107 src/wheezy/validation/model.py:108
+#: src/wheezy/validation/model.py:109
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:108 src/wheezy/validation/model.py:112
-#: src/wheezy/validation/model.py:113
+#: src/wheezy/validation/model.py:112
+msgid "Input was not in a correct format."
+msgstr "Input was not in a correct format."
+
+#: src/wheezy/validation/model.py:113 src/wheezy/validation/model.py:117
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/rules.py:17 src/wheezy/validation/rules.py:20
 #: src/wheezy/validation/rules.py:25
 msgid "Required field cannot be left blank."
 msgstr "Required field cannot be left blank."
 
-#: src/wheezy/validation/rules.py:87 src/wheezy/validation/rules.py:90
 #: src/wheezy/validation/rules.py:95 src/wheezy/validation/rules.py:98
 #, python-format
 msgid "Required to be a minimum of %(min)d characters in length."
 msgstr "Required to be a minimum of %(min)d characters in length."
 
-#: src/wheezy/validation/rules.py:92 src/wheezy/validation/rules.py:95
 #: src/wheezy/validation/rules.py:100 src/wheezy/validation/rules.py:103
 #, python-format
 msgid "The length must fall within the range %(min)d - %(max)d characters."
 msgstr "The length must fall within the range %(min)d - %(max)d characters."
 
-#: src/wheezy/validation/rules.py:99 src/wheezy/validation/rules.py:102
 #: src/wheezy/validation/rules.py:107 src/wheezy/validation/rules.py:110
 #, python-format
 msgid "Exceeds maximum length of %(max)d."
 msgstr "Exceeds maximum length of %(max)d."
 
-#: src/wheezy/validation/rules.py:224 src/wheezy/validation/rules.py:227
 #: src/wheezy/validation/rules.py:232 src/wheezy/validation/rules.py:235
 #, python-format
 msgid "The value failed equality comparison with \"%(comparand)s\"."
 msgstr "The value failed equality comparison with \"%(comparand)s\"."
 
-#: src/wheezy/validation/rules.py:290 src/wheezy/validation/rules.py:295
 #: src/wheezy/validation/rules.py:298
 msgid "Required to match validation pattern."
 msgstr "Required to match validation pattern."
 
-#: src/wheezy/validation/rules.py:322 src/wheezy/validation/rules.py:327
 #: src/wheezy/validation/rules.py:330
 msgid ""
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "hyphens."
 
-#: src/wheezy/validation/rules.py:354 src/wheezy/validation/rules.py:359
 #: src/wheezy/validation/rules.py:362
 msgid "Required to be a valid email address."
 msgstr "Required to be a valid email address."
 
-#: src/wheezy/validation/rules.py:402 src/wheezy/validation/rules.py:407
 #: src/wheezy/validation/rules.py:410
 #, python-format
 msgid "Required to be greater or equal to %(min)s."
 msgstr "Required to be greater or equal to %(min)s."
 
-#: src/wheezy/validation/rules.py:406 src/wheezy/validation/rules.py:411
 #: src/wheezy/validation/rules.py:414
 #, python-format
 msgid "The value must fall within the range %(min)s - %(max)s"
 msgstr "The value must fall within the range %(min)s - %(max)s"
 
-#: src/wheezy/validation/rules.py:413 src/wheezy/validation/rules.py:418
 #: src/wheezy/validation/rules.py:421
 #, python-format
 msgid "Exceeds maximum allowed value of %(max)s."

File i18n/ru/LC_MESSAGES/validation.po

 msgid "The value '%s' is not in one of supported formats."
 msgstr "Значение '%s' не соответсвует ни одному из поддеживаемых форматов."
 
+#: src/wheezy/validation/model.py:112
+msgid "Input was not in a correct format."
+msgstr "Ввод не в правильном формате."
+
 #: src/wheezy/validation/rules.py:12
 msgid "Required field cannot be left blank."
 msgstr "Обязательное поле не может быть пустым."

File i18n/validation.po

 msgstr "%H:%M"
 
 #. fallback time input formats: 16:34:52. Use | to separate multiple values.
-#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:20
-#: src/wheezy/validation/format.py:21
+#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:21
 msgid "%H:%M:%S"
 msgstr "%H:%M:%S"
 
 #. default datetime input format: 2008/5/18 16:34
-#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:22
-#: src/wheezy/validation/format.py:23
+#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:23
 msgid "%Y/%m/%d %H:%M"
 msgstr "%Y/%m/%d %H:%M"
 
 #. fallback datetime input formats: 2008/5/18 16:34:52. Use | to separate.
-#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:23
-#: src/wheezy/validation/format.py:26 src/wheezy/validation/format.py:27
+#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:26
+#: src/wheezy/validation/format.py:27
 msgid ""
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:81 src/wheezy/validation/model.py:82
-#: src/wheezy/validation/model.py:91 src/wheezy/validation/model.py:103
-#: src/wheezy/validation/model.py:107 src/wheezy/validation/model.py:108
+#: src/wheezy/validation/model.py:109
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:108 src/wheezy/validation/model.py:112
-#: src/wheezy/validation/model.py:113
+#: src/wheezy/validation/model.py:112
+msgid "Input was not in a correct format."
+msgstr "Input was not in a correct format."
+
+#: src/wheezy/validation/model.py:113 src/wheezy/validation/model.py:117
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/rules.py:17 src/wheezy/validation/rules.py:20
 #: src/wheezy/validation/rules.py:25
 msgid "Required field cannot be left blank."
 msgstr "Required field cannot be left blank."
 
-#: src/wheezy/validation/rules.py:87 src/wheezy/validation/rules.py:90
 #: src/wheezy/validation/rules.py:95 src/wheezy/validation/rules.py:98
 #, python-format
 msgid "Required to be a minimum of %(min)d characters in length."
 msgstr "Required to be a minimum of %(min)d characters in length."
 
-#: src/wheezy/validation/rules.py:92 src/wheezy/validation/rules.py:95
 #: src/wheezy/validation/rules.py:100 src/wheezy/validation/rules.py:103
 #, python-format
 msgid "The length must fall within the range %(min)d - %(max)d characters."
 msgstr "The length must fall within the range %(min)d - %(max)d characters."
 
-#: src/wheezy/validation/rules.py:99 src/wheezy/validation/rules.py:102
 #: src/wheezy/validation/rules.py:107 src/wheezy/validation/rules.py:110
 #, python-format
 msgid "Exceeds maximum length of %(max)d."
 msgstr "Exceeds maximum length of %(max)d."
 
-#: src/wheezy/validation/rules.py:224 src/wheezy/validation/rules.py:227
 #: src/wheezy/validation/rules.py:232 src/wheezy/validation/rules.py:235
 #, python-format
 msgid "The value failed equality comparison with \"%(comparand)s\"."
 msgstr "The value failed equality comparison with \"%(comparand)s\"."
 
-#: src/wheezy/validation/rules.py:290 src/wheezy/validation/rules.py:295
 #: src/wheezy/validation/rules.py:298
 msgid "Required to match validation pattern."
 msgstr "Required to match validation pattern."
 
-#: src/wheezy/validation/rules.py:322 src/wheezy/validation/rules.py:327
 #: src/wheezy/validation/rules.py:330
 msgid ""
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "hyphens."
 
-#: src/wheezy/validation/rules.py:354 src/wheezy/validation/rules.py:359
 #: src/wheezy/validation/rules.py:362
 msgid "Required to be a valid email address."
 msgstr "Required to be a valid email address."
 
-#: src/wheezy/validation/rules.py:402 src/wheezy/validation/rules.py:407
 #: src/wheezy/validation/rules.py:410
 #, python-format
 msgid "Required to be greater or equal to %(min)s."
 msgstr "Required to be greater or equal to %(min)s."
 
-#: src/wheezy/validation/rules.py:406 src/wheezy/validation/rules.py:411
 #: src/wheezy/validation/rules.py:414
 #, python-format
 msgid "The value must fall within the range %(min)s - %(max)s"
 msgstr "The value must fall within the range %(min)s - %(max)s"
 
-#: src/wheezy/validation/rules.py:413 src/wheezy/validation/rules.py:418
 #: src/wheezy/validation/rules.py:421
 #, python-format
 msgid "Exceeds maximum allowed value of %(max)s."

File src/wheezy/validation/model.py

 
         Invalid values:
 
-        >>> values = {'balance': ['x'], 'age': ['x'], 'birthday': ['4.2.12']}
+        >>> values = {'balance': ['x'], 'age': [''], 'birthday': ['4.2.12']}
         >>> user = User()
         >>> try_update_model(user, values, results)
         False
                 original_value = value
                 value = value_provider(value, gettext)
             except (ArithmeticError, ValueError):
-                results[name] = [gettext(
-                    "The value '%s' is invalid.") % value]
+                if original_value:
+                    results[name] = [gettext(
+                        "The value '%s' is invalid.") % original_value]
+                else:
+                    results[name] = [gettext(
+                        "Input was not in a correct format.")]
                 succeed = False
             else:
                 if value is None: