diff --git a/include/valijson/constraints/concrete_constraints.hpp b/include/valijson/constraints/concrete_constraints.hpp index 536f7ed..8ba30e2 100644 --- a/include/valijson/constraints/concrete_constraints.hpp +++ b/include/valijson/constraints/concrete_constraints.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -784,6 +785,11 @@ public: void setDivisor(double newValue) { + if (!std::isfinite(newValue) || newValue <= 0.0) { + throwRuntimeError( + "Divisor for 'multipleOf' or 'divisibleBy' must be positive"); + } + m_value = newValue; } @@ -813,6 +819,11 @@ public: void setDivisor(int64_t newValue) { + if (newValue <= 0) { + throwRuntimeError( + "Divisor for 'multipleOf' or 'divisibleBy' must be positive"); + } + m_value = newValue; }