Skip to content
This repository was archived by the owner on Aug 16, 2026. It is now read-only.

Commit 1997dbf

Browse files
committed
Finished renames
1 parent 3358a1e commit 1997dbf

19 files changed

Lines changed: 196 additions & 267 deletions

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ $ wsjcpp install "https://github.com/wsjcpp/wsjcpp-validators:master"
2222

2323
``` cpp
2424

25-
WsjcppValidatorUUID *pValidatorUUID = new WsjcppValidatorUUID();
25+
validator_uuid *pValidatorUUID = new validator_uuid();
2626
std::string sError = "";
27-
if (!pValidatorUUID->isValid("abcdef01-ABCD-EF23-1000-000000000001", sError)) {
27+
if (!pValidatorUUID->is_valid("abcdef01-ABCD-EF23-1000-000000000001", sError)) {
2828
std::cout << sError << std::endl;
2929
}
3030
```
@@ -36,39 +36,39 @@ Classes for data validation
3636
- `new WsjcppValidatorStringRegexpBase("testre", "^[a-zA-Z]+$")` - validate value by regular expression
3737
- `new WsjcppValidatorStringListBase("lang", {"en", "de", "ru"})` - validate value from a list
3838
- `new WsjcppValidatorEmail()` - validate format email
39-
- `new WsjcppValidatorUUID()` - validate format uuid
40-
- `new WsjcppValidatorStringLength(1,100)` - validate min length and max length
41-
- `new WsjcppValidatorJWT()` - validate format of JWT
39+
- `new validator_uuid()` - validate format uuid
40+
- `new validator_strlen(1,100)` - validate min length and max length
41+
- `new validator_jwt()` - validate format of JWT
4242
- `new WsjcppValidatorDate()` - validate format date like 'YYYY-MM-DD'
43-
- `new WsjcppValidatorTimeH24()` - validate format date like 'HH:mm:ss' (24 hours)
43+
- `new validator_time24()` - validate format date like 'HH:mm:ss' (24 hours)
4444
- `new WsjcppValidatorDateTime()` - validate format date like 'YYYY-MM-DD\THH:mm:ss'
4545
- `new WsjcppValidatorURL()` - validate format of url
46-
- `new WsjcppValidatorBase64()` - validate format of base64
46+
- `new validator_base64()` - validate format of base64
4747
- `new WsjcppValidatorNumber()` - validate format of number
4848
- `new WsjcppValidatorHex()` - validate hex value
4949
- `new WsjcppValidatorIntegerMinValue(1)` - validate integer min value
5050
- `new WsjcppValidatorIntegerMaxValue(100)` - validate integer max value
5151
5252
## Completed static functions
5353
54-
- `WsjcppValidators::isValidDate(const std::string &sValue, std::string &sError)`
55-
- `WsjcppValidators::isValidTimeH24(const std::string &sValue, std::string &sError)`
56-
- `WsjcppValidators::isValidDomainName(const std::string &sValue, std::string &sError)`
57-
- `WsjcppValidators::isValidBase64(const std::string &sValue, std::string &sError)`
58-
- `WsjcppValidators::isValidIPv4(const std::string &sValue, std::string &sError)`
59-
- `WsjcppValidators::isValidIPv6(const std::string &sValue, std::string &sError)`
54+
- `WsjcppValidators::is_validDate(const std::string &sValue, std::string &sError)`
55+
- `WsjcppValidators::is_validTimeH24(const std::string &sValue, std::string &sError)`
56+
- `WsjcppValidators::is_validDomainName(const std::string &sValue, std::string &sError)`
57+
- `WsjcppValidators::is_validBase64(const std::string &sValue, std::string &sError)`
58+
- `WsjcppValidators::is_validIPv4(const std::string &sValue, std::string &sError)`
59+
- `WsjcppValidators::is_validIPv6(const std::string &sValue, std::string &sError)`
6060
6161
## Example for your implementations
6262
6363
``` cpp
64-
class WsjcppValidatorUUID : public WsjcppValidatorStringRegexpBase {
64+
class validator_uuid : public WsjcppValidatorStringRegexpBase {
6565
public:
66-
WsjcppValidatorUUID()
66+
validator_uuid()
6767
: WsjcppValidatorStringRegexpBase(
6868
"uuid", // name
6969
"^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$"
7070
) {
71-
TAG = "WsjcppValidatorUUID";
71+
TAG = "validator_uuid";
7272
}
7373
};
7474
```

src/main.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,35 @@ int main(int argc, char *argv[]) {
4949
}
5050
std::string sArg1(argv[1]);
5151

52-
std::vector<wsjcpp::WsjcppValidatorStringBase *> vValidators;
53-
// vValidators.push_back(new WsjcppValidatorStringLength(5, 100));
54-
// vValidators.push_back(new WsjcppValidatorStringLength(1, 5));
55-
vValidators.push_back(new wsjcpp::WsjcppValidatorEmail());
56-
vValidators.push_back(new wsjcpp::WsjcppValidatorUUID());
57-
vValidators.push_back(new wsjcpp::WsjcppValidatorStringListBase("lang", {"en", "de", "ru"}));
58-
vValidators.push_back(new wsjcpp::WsjcppValidatorStringRegexpBase("testre", "^[a-zA-Z]+$"));
59-
vValidators.push_back(new wsjcpp::WsjcppValidatorJWT());
60-
vValidators.push_back(new wsjcpp::WsjcppValidatorDate());
61-
vValidators.push_back(new wsjcpp::WsjcppValidatorTimeH24());
62-
vValidators.push_back(new wsjcpp::WsjcppValidatorDateTime());
63-
// vValidators.push_back(new WsjcppValidatorURL());
64-
vValidators.push_back(new wsjcpp::WsjcppValidatorBase64());
65-
vValidators.push_back(new wsjcpp::WsjcppValidatorNumber());
66-
vValidators.push_back(new wsjcpp::WsjcppValidatorHex());
52+
std::vector<wsjcpp::validator<std::string> *> validators;
53+
// validators.push_back(new validator_strlen(5, 100));
54+
// validators.push_back(new validator_strlen(1, 5));
55+
validators.push_back(new wsjcpp::validator_email());
56+
validators.push_back(new wsjcpp::validator_uuid());
57+
validators.push_back(new wsjcpp::validator_str_list("lang", {"en", "de", "ru"}));
58+
validators.push_back(new wsjcpp::validator_regexp("testre", "^[a-zA-Z]+$"));
59+
validators.push_back(new wsjcpp::validator_jwt());
60+
// validators.push_back(new wsjcpp::validator_date());
61+
validators.push_back(new wsjcpp::validator_time24());
62+
validators.push_back(new wsjcpp::validator_datetime());
63+
validators.push_back(new wsjcpp::validator_url());
64+
validators.push_back(new wsjcpp::validator_base64());
65+
validators.push_back(new wsjcpp::validator_int());
66+
validators.push_back(new wsjcpp::validator_hex());
6767

6868
std::string sResult = "";
69-
for (int i = 0; i < vValidators.size(); i++) {
70-
wsjcpp::WsjcppValidatorStringBase *pValidator = vValidators[i];
69+
for (int i = 0; i < validators.size(); i++) {
70+
wsjcpp::validator<std::string> *pValidator = validators[i];
7171
std::string sError;
7272
if (sResult.size() > 0) {
7373
sResult += ",";
7474
}
75-
if (pValidator->isValid(sArg1, sError)) {
76-
sResult += " +" + pValidator->getTypeName();
77-
// WsjcppLog::ok(TAG, "ok -> [" + pValidator->getTypeName() + "]: '" + sArg1 + "'");
75+
if (pValidator->is_valid(sArg1, sError)) {
76+
sResult += " +" + pValidator->name();
77+
// WsjcppLog::ok(TAG, "ok -> [" + pValidator->name() + "]: '" + sArg1 + "'");
7878
} else {
79-
sResult += " -" + pValidator->getTypeName();
80-
// WsjcppLog::err(TAG, "fail -> [" + pValidator->getTypeName() + "]: '" + sArg1 + "' - " + sError);
79+
sResult += " -" + pValidator->name();
80+
// WsjcppLog::err(TAG, "fail -> [" + pValidator->name() + "]: '" + sArg1 + "' - " + sError);
8181
}
8282
}
8383
std::cout << sResult << std::endl;

src/tests/test_is_validator_base64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ int main() {
2424
tests.push_back(local("+/11", true));
2525
tests.push_back(local("%$", false));
2626

27-
wsjcpp::WsjcppValidatorBase64 *pValidator = new wsjcpp::WsjcppValidatorBase64();
27+
wsjcpp::validator_base64 *pValidator = new wsjcpp::validator_base64();
2828

2929
for (int i = 0; i < tests.size(); i++) {
3030
local t = tests[i];
3131
std::string error;
32-
bool got = pValidator->isValid(t.value, error);
32+
bool got = pValidator->is_valid(t.value, error);
3333
if (got != t.expected) {
3434
found_errors++;
3535
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

src/tests/test_is_validator_date.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ int main() {
2929
tests.push_back(local("1898-15-01", false));
3030
tests.push_back(local("1898-01-32", false));
3131

32-
wsjcpp::WsjcppValidatorDate *pValidator = new wsjcpp::WsjcppValidatorDate();
32+
wsjcpp::validator_date *pValidator = new wsjcpp::validator_date();
3333

3434
for (int i = 0; i < tests.size(); i++) {
3535
local t = tests[i];
3636
std::string error;
37-
bool got = pValidator->isValid(t.value, error);
37+
bool got = pValidator->is_valid(t.value, error);
3838
if (got != t.expected) {
3939
found_errors++;
4040
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

src/tests/test_is_validator_datetime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ int main() {
2727
tests.push_back(local("18a8-01-01T00:00:00", false));
2828
tests.push_back(local("1838-01-01T25:00:00", false));
2929

30-
wsjcpp::WsjcppValidatorDateTime *pValidator = new wsjcpp::WsjcppValidatorDateTime();
30+
wsjcpp::validator_datetime *pValidator = new wsjcpp::validator_datetime();
3131

3232
for (int i = 0; i < tests.size(); i++) {
3333
local t = tests[i];
3434
std::string error;
35-
bool got = pValidator->isValid(t.value, error);
35+
bool got = pValidator->is_valid(t.value, error);
3636
if (got != t.expected) {
3737
found_errors++;
3838
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

src/tests/test_is_validator_email.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ int main() {
2424
tests.push_back(local("s_s-some@test.com", true));
2525
tests.push_back(local("s_s-some@test.c", false));
2626

27-
wsjcpp::WsjcppValidatorEmail *pValidator = new wsjcpp::WsjcppValidatorEmail();
27+
wsjcpp::validator_email *pValidator = new wsjcpp::validator_email();
2828

2929
for (int i = 0; i < tests.size(); i++) {
3030
local t = tests[i];
3131
std::string error;
32-
bool got = pValidator->isValid(t.value, error);
32+
bool got = pValidator->is_valid(t.value, error);
3333
if (got != t.expected) {
3434
found_errors++;
3535
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

src/tests/test_is_validator_hex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ int main() {
2222
tests.push_back(local("abcdef0123456789ABCDEF", true));
2323
tests.push_back(local("0123J", false));
2424

25-
wsjcpp::WsjcppValidatorHex *pValidator = new wsjcpp::WsjcppValidatorHex();
25+
wsjcpp::validator_hex *pValidator = new wsjcpp::validator_hex();
2626

2727
for (int i = 0; i < tests.size(); i++) {
2828
local t = tests[i];
2929
std::string error;
30-
bool got = pValidator->isValid(t.value, error);
30+
bool got = pValidator->is_valid(t.value, error);
3131
if (got != t.expected) {
3232
found_errors++;
3333
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ int main() {
2525
tests.push_back(local("", false));
2626
tests.push_back(local("+2020", false));
2727

28-
wsjcpp::WsjcppValidatorNumber *pValidator = new wsjcpp::WsjcppValidatorNumber();
28+
wsjcpp::validator_int *pValidator = new wsjcpp::validator_int();
2929

3030
for (int i = 0; i < tests.size(); i++) {
3131
local t = tests[i];
3232
std::string error;
33-
bool got = pValidator->isValid(t.value, error);
33+
bool got = pValidator->is_valid(t.value, error);
3434
if (got != t.expected) {
3535
found_errors++;
3636
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

src/tests/test_is_validator_integer_max_value.cpp renamed to src/tests/test_is_validator_int_max.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ int main() {
2323
tests.push_back(local(1001, false));
2424
tests.push_back(local(100100000, false));
2525

26-
wsjcpp::WsjcppValidatorIntegerMaxValue *pValidator = new wsjcpp::WsjcppValidatorIntegerMaxValue(1000);
26+
wsjcpp::validator_int_max *pValidator = new wsjcpp::validator_int_max(1000);
2727

2828
for (int i = 0; i < tests.size(); i++) {
2929
local t = tests[i];
3030
std::string error;
31-
bool got = pValidator->isValid(t.value, error);
31+
bool got = pValidator->is_valid(t.value, error);
3232
if (got != t.expected) {
3333
found_errors++;
3434
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

src/tests/test_is_validator_integer_min_value.cpp renamed to src/tests/test_is_validator_int_min.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ int main() {
2424
tests.push_back(local(1001, true));
2525
tests.push_back(local(100100000, true));
2626

27-
wsjcpp::WsjcppValidatorIntegerMinValue *pValidator = new wsjcpp::WsjcppValidatorIntegerMinValue(1);
27+
wsjcpp::validator_int_min *pValidator = new wsjcpp::validator_int_min(1);
2828

2929
for (int i = 0; i < tests.size(); i++) {
3030
local t = tests[i];
3131
std::string error;
32-
bool got = pValidator->isValid(t.value, error);
32+
bool got = pValidator->is_valid(t.value, error);
3333
if (got != t.expected) {
3434
found_errors++;
3535
std::cerr << "Expected " << (t.expected ? "true" : "false") << ", but got " << (got ? "true" : "false") << " for "

0 commit comments

Comments
 (0)