1+ #include < string.h>
2+ #include < iostream>
3+ #include < algorithm>
4+ #include < wsjcpp_core.h>
5+ #include < wsjcpp_validators.h>
6+
7+ int main (int argc, char * argv[]) {
8+ std::string TAG = " MAIN" ;
9+
10+ if (!WSJCppCore::dirExists (" .wsjcpp" )) {
11+ WSJCppCore::makeDir (" .wsjcpp" );
12+ }
13+ std::string appLogPath = " .wsjcpp/logs" ;
14+ if (!WSJCppCore::dirExists (appLogPath)) {
15+ WSJCppCore::makeDir (appLogPath);
16+ }
17+ WSJCppLog::setPrefixLogFile (" wsjcpp_validators" );
18+ WSJCppLog::setLogDirectory (" .wsjcpp/logs" );
19+
20+ WSJCppLog::info (TAG, " Hello" );
21+ WSJCppCore::init (
22+ argc, argv,
23+ std::string (WSJCPP_NAME),
24+ std::string (WSJCPP_VERSION),
25+ " Evgenii Sopov" ,
26+ " "
27+ );
28+ if (argc != 2 ) {
29+ std::cout << " Usage " << argv[0 ] << " something" << std::endl;
30+ return -1 ;
31+ }
32+ std::string sArg1 (argv[1 ]);
33+
34+ std::vector<WJSCppValidatorStringBase *> vValidators;
35+ vValidators.push_back (new WJSCppValidatorStringLength (5 , 100 ));
36+ vValidators.push_back (new WJSCppValidatorStringLength (1 , 5 ));
37+ vValidators.push_back (new WJSCppValidatorEmail ());
38+ vValidators.push_back (new WJSCppValidatorUUID ());
39+ vValidators.push_back (new WJSCppValidatorStringListBase (" lang" , {" en" , " de" , " ru" }));
40+ vValidators.push_back (new WJSCppValidatorStringRegexpBase (" testre" , " ^[a-zA-Z]+$" ));
41+
42+ for (int i = 0 ; i < vValidators.size (); i++) {
43+ WJSCppValidatorStringBase *pValidator = vValidators[i];
44+ std::string sError ;
45+ if (pValidator->isValid (sArg1 , sError )) {
46+ WSJCppLog::ok (TAG, " ok -> [" + pValidator->getTypeName () + " ]: '" + sArg1 + " '" );
47+ } else {
48+ WSJCppLog::err (TAG, " fail -> [" + pValidator->getTypeName () + " ]: '" + sArg1 + " ' - " + sError );
49+ }
50+ }
51+
52+ return 0 ;
53+ }
0 commit comments