Add range check to MaxItemsConstraint and MaxLengthConstraint classes

This commit is contained in:
Tristan Penman 2016-01-14 15:57:37 +11:00
parent 2bcaaac344
commit 0f81f72a26

View File

@ -437,6 +437,11 @@ public:
void setMaxItems(int64_t newMaxItems)
{
if (newMaxItems < 0) {
throw std::runtime_error(
"Maximum number of items must be a non-negative integer");
}
maxItems = newMaxItems;
}
@ -464,6 +469,11 @@ public:
void setMaxLength(int64_t newMaxLength)
{
if (newMaxLength < 0) {
throw std::runtime_error(
"Maximum length must be a non-negative integer");
}
maxLength = newMaxLength;
}