-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathValidations.h
45 lines (39 loc) · 851 Bytes
/
Validations.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Created by victor on 4/11/17.
//
#ifndef RESTDBXX_VALIDATIONS_H
#define RESTDBXX_VALIDATIONS_H
#include <string>
#include <boost/algorithm/string.hpp>
namespace restdbxx {
class Validations {
public:
/**
* @brief
* @param email
* @return
*/
static bool is_valid_email(const std::string &email);
/**
* @brief
* @param path
* @return
*/
static bool is_valid_path(const std::string &path);
/**
* @brief
* @param path
*/
static void sanitize_path(std::string &path);
static std::string get_endpoint_from_path(const std::string &path) {
std::vector<std::string> parts;
boost::algorithm::split(parts, path, boost::is_any_of("/"), boost::token_compress_on);
if (parts.empty()) {
return "/";
} else {
return "/" + parts[0];
}
}
};
}
#endif //RESTDBXX_VALIDATIONS_H