SectionPairIdentifierValidator.cpp 1.1 KB

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