This commit is contained in:
Alexander Aleksandrovič Klimov 2026-02-03 15:23:52 +01:00 committed by GitHub
commit f78a46ed39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 0 deletions

View file

@ -583,6 +583,14 @@ void Downtime::ValidateEndTime(const Lazy<Timestamp>& lvalue, const ValidationUt
BOOST_THROW_EXCEPTION(ValidationError(this, { "end_time" }, "End time must be greater than 0."));
}
void Downtime::ValidateDuration(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils)
{
ObjectImpl<Downtime>::ValidateDuration(lvalue, utils);
if (lvalue() < 0)
BOOST_THROW_EXCEPTION(ValidationError(this, { "duration" }, "Duration must be positive."));
}
DowntimeChildOptions Downtime::ChildOptionsFromValue(const Value& options)
{
if (options == "DowntimeNoChildren")

View file

@ -83,6 +83,7 @@ protected:
void ValidateStartTime(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
void ValidateEndTime(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
void ValidateDuration(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
private:
ObjectImpl<Checkable>::Ptr m_Checkable;

View file

@ -88,6 +88,14 @@ void ScheduledDowntime::Start(bool runtimeCreated)
Utility::QueueAsyncCallback([this]() { CreateNextDowntime(); });
}
void ScheduledDowntime::ValidateDuration(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils)
{
ObjectImpl<ScheduledDowntime>::ValidateDuration(lvalue, utils);
if (lvalue() < 0)
BOOST_THROW_EXCEPTION(ValidationError(this, { "duration" }, "Duration must be positive."));
}
void ScheduledDowntime::TimerProc()
{
for (const ScheduledDowntime::Ptr& sd : ConfigType::GetObjectsByType<ScheduledDowntime>()) {

View file

@ -40,6 +40,7 @@ public:
protected:
void OnAllConfigLoaded() override;
void Start(bool runtimeCreated) override;
void ValidateDuration(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
private:
static void TimerProc();