static
| 593 | |
| 594 | // static |
| 595 | bool 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 |
| 631 | bool EditableMapObject::ValidateLevel(string const & level) |