SectionPairIdentifierValidator.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-09
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <ls-std/io/section-pair/validator/SectionPairIdentifierValidator.hpp>
  11. #include <regex>
  12. using ls::standard::core::Class;
  13. using ls::standard::io::section_pair_identifier;
  14. using ls::standard::io::SectionPairIdentifierValidator;
  15. using std::move;
  16. using std::regex;
  17. using std::regex_match;
  18. using std::string;
  19. SectionPairIdentifierValidator::SectionPairIdentifierValidator(section_pair_identifier _identifier) : Class("SectionPairIdentifierValidator"), identifier(::move(_identifier))
  20. {}
  21. SectionPairIdentifierValidator::~SectionPairIdentifierValidator() noexcept = default;
  22. string SectionPairIdentifierValidator::getValidationRegex()
  23. {
  24. return _getValidationRegex();
  25. }
  26. bool SectionPairIdentifierValidator::isValid()
  27. {
  28. static regex identifierRegex("^" + _getValidationRegex());
  29. return regex_match(this->identifier, identifierRegex);
  30. }
  31. string SectionPairIdentifierValidator::_getValidationRegex()
  32. {
  33. return R"([a-z]([a-z0-9-]){1,63})";
  34. }