MCPcopy Create free account
hub / github.com/comaps/comaps / ValidateEmail

Method ValidateEmail

libs/indexer/editable_map_object.cpp:595–628  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

593
594// static
595bool EditableMapObject::ValidateEmail(string const & email)
596{
597 if (email.empty())
598 return true;
599
600 if (strings::CountChar(email) > kMaximumOsmChars)
601 return false;
602
603 if (strings::IsASCIIString(email))
604 {
605 static std::regex const s_emailRegex(R"(^(?!mailto:)[^@\s]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$)", std::regex_constants::icase);
606 return regex_match(email, s_emailRegex);
607 }
608
609 if ('@' == email.front() || '@' == email.back())
610 return false;
611
612 if ('.' == email.back())
613 return false;
614
615 auto const atPos = find(begin(email), end(email), '@');
616 if (atPos == end(email))
617 return false;
618
619 // There should be only one '@' sign.
620 if (find(next(atPos), end(email), '@') != end(email))
621 return false;
622
623 // There should be at least one '.' sign after '@'
624 if (find(next(atPos), end(email), '.') == end(email))
625 return false;
626
627 return true;
628}
629
630// static
631bool EditableMapObject::ValidateLevel(string const & level)

Callers

nothing calls this directly

Calls 8

CountCharFunction · 0.85
IsASCIIStringFunction · 0.85
findFunction · 0.85
frontMethod · 0.80
backMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected