escaper = $escaper ?: ObjectManager::getInstance()->create(Escaper::class); } /** * Throw exception if Ttl data is invalid or empty * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeSave() { $value = $this->getValue(); if ($value < 0 || !preg_match('/^[0-9]+$/', $value)) { throw new \Magento\Framework\Exception\LocalizedException( __( 'Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.', $this->escaper->escapeHtml($value) ) ); } return $this; } }