/*
* Author:          Patrick-Christopher Mattulat
* Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-02-09
* Changed:         2026-06-23
*
* */

#include <ls-std/io/section-pair/validator/SectionPairValueValidator.hpp>
#include <regex>

using ls::standard::core::Class;
using ls::standard::io::section_pair_row_value;
using ls::standard::io::SectionPairValueValidator;
using std::move;
using std::regex;
using std::regex_match;
using std::string;

SectionPairValueValidator::SectionPairValueValidator(section_pair_row_value _value) : Class("SectionPairValueValidator"), value(::move(_value))
{}

SectionPairValueValidator::~SectionPairValueValidator() noexcept = default;

string SectionPairValueValidator::getValidationRegex()
{
  return _getValidationRegex();
}

bool SectionPairValueValidator::isValid()
{
  const string validationRegex = _getValidationRegex();
  const string concatenation = "(^" + validationRegex + ")|(^" + validationRegex + R"(\n{1})|(^)" + validationRegex + R"(\r{1}\n{1}))";
  static regex valueRegex{concatenation};

  return regex_match(this->value, valueRegex);
}

string SectionPairValueValidator::_getValidationRegex()
{
  string value = R"([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512})";
  return value;
}
