summaryrefslogtreecommitdiff
path: root/buildscripts/idl/idl/errors.py
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2018-09-26 15:17:56 +0000
committerSara Golemon <sara.golemon@mongodb.com>2018-10-05 23:33:33 +0000
commitf9600749453db5dec58bd1bbfd967e16b1578a24 (patch)
tree22e0f6e8f773483ad12828d92f4bf8d1496fbe70 /buildscripts/idl/idl/errors.py
parent2db04b524dc5e2121b74829814db7c8e84e5696d (diff)
downloadmongo-f9600749453db5dec58bd1bbfd967e16b1578a24.tar.gz
SERVER-37168 Add validators for IDL fields
Diffstat (limited to 'buildscripts/idl/idl/errors.py')
-rw-r--r--buildscripts/idl/idl/errors.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/buildscripts/idl/idl/errors.py b/buildscripts/idl/idl/errors.py
index 9fc78547f8c..b9785c2bf66 100644
--- a/buildscripts/idl/idl/errors.py
+++ b/buildscripts/idl/idl/errors.py
@@ -85,6 +85,7 @@ ERROR_ID_IS_NODE_VALID_INT = "ID0049"
ERROR_ID_IS_NODE_VALID_NON_NEGATIVE_INT = "ID0050"
ERROR_ID_IS_DUPLICATE_COMPARISON_ORDER = "ID0051"
ERROR_ID_IS_COMMAND_TYPE_EXTRANEOUS = "ID0052"
+ERROR_ID_VALUE_NOT_NUMERIC = "ID0053"
class IDLError(Exception):
@@ -665,6 +666,14 @@ class ParserContext(object):
("Command '%s' cannot have a 'type' property unless namespace equals 'type'.") %
(command_name))
+ def add_value_not_numeric_error(self, location, attrname, value):
+ # type: (common.SourceLocation, unicode, unicode) -> None
+ """Add an error about non-numeric value where number expected."""
+ # pylint: disable=invalid-name
+ self._add_error(location, ERROR_ID_VALUE_NOT_NUMERIC,
+ ("'%s' requires a numeric value, but %s can not be cast") % (attrname,
+ value))
+
def _assert_unique_error_messages():
# type: () -> None