You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,23 @@
2
2
3
3
## Motivation
4
4
5
-
A common issue when receiving data either by application from user interface or by server remotely from clients is verifying data integrity and/or specific constraints. A typical approach for implementing complex data validation is writing nested *if-conditions* or chained invocations of partial validation methods. Declarations of the constraints could become intermixed with their implementations. Thus, validation would spread over the code which makes it hard to maintain it. Requirement to construct and show error messages could make everything still more complicated.
5
+
Checking data constraints or verifying data integrity is a very common task in programming. A typical approach for complex data validation is writing nested *if-conditions* or chained invocations of partial validation methods. Declarations of the constraints could become intermixed with their implementations, thus, spreading the validation routines over the code. Requirements to construct and show error messages could make everything even more complicated.
6
6
7
-
`cpp-validator` library allows one to declare data constraints with clean statements in certain points of code and apply them in other points of code on demand. If needed, the validation error messages are automatically constructed by taking into account the user's locale.
7
+
`cpp-validator` library allows one to declare data constraints with clean statements in certain points of code and apply them in other parts of code on demand. If needed, the validation error messages are automatically constructed by taking into account the user's locale.
Copy file name to clipboardExpand all lines: docs/index.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -989,7 +989,7 @@ There is also a [contains](#contains) operator added to the library for convenie
989
989
990
990
A [member](#member) existence can also be checked implicitly before applying validation to the [member](#member). Check of member existence is performed by an [adapter](#adapter) if the [adapter](#adapter) supports that. [Default adapter](#default-adapter) and [reporting adapter](#reporting-adapter) provide this feature which can be configured with `set_check_member_exists_before_validation` and `set_unknown_member_mode` adapter methods.
991
991
992
-
Method `set_check_member_exists_before_validation` enables/disables implicit check of member existence. By default this option is disabled which improves validation performance but can sometimes cause exceptions or other undefined errors. Note that some basic check of property existence or type compatibility might be performed statically at compile time regardless of this flag.
992
+
Method `set_check_member_exists_before_validation` enables/disables implicit check of member existence. By default this option is disabled which improves validation performance but can sometimes cause exceptions or other undefined errors. Note that some basic check of property existence or type compatibility might be performed statically at compilation time regardless of this flag.
993
993
994
994
Method `set_unknown_member_mode` instructs adapter what to do if a member is not found. There are two options:
995
995
- ignore missed members and continue validation process;
@@ -2324,7 +2324,7 @@ int main()
2324
2324
There are a few built-in adapter types implemented in `cpp-validator` library:
2325
2325
- [default adapter](#default-adapter) that applies validation to an [object](#object) by invoking [operators](#operator) one by one as specified in a [validator](#validator);
2326
2326
- [reporting adapter](#reporting-adapter) that does the same as [default adapter](#default-adapter) with addition of constructing a [report](#report) describing an error if validation fails;
2327
-
- [failed members adapter](#failed-members-adapter) that collects names of object's members that didn't path validation;
2327
+
- [failed members adapter](#failed-members-adapter) that collects names of object's members that failed to pass validation;
2328
2328
- [prevalidation adapter](#prevalidation-adapter) that validates only one [member](#member) and constructs a [report](#report) if validation fails;
2329
2329
- [filtering adapter](#partial-validation) used to filter member paths before validation.
2330
2330
@@ -2337,7 +2337,7 @@ There are a few built-in adapter types implemented in `cpp-validator` library:
2337
2337
### Failed members adapter
2338
2338
2339
2339
Failed members adapter is used to collect all members that did not pass the validation.
2340
-
This adapter is defined in `hatn/validator/adapters/reporting_adapter.hpp` header. Call `make_failed_members_adapter(obj)` to make adapter for object that must be validated. The list of failed member names can be accessed via `adapter.traits().reporter().failed_members()` after validation.
2340
+
This adapter is defined in `hatn/validator/adapters/failed_members_adapter.hpp` header file. Call `make_failed_members_adapter(obj)` to make adapter for object that must be validated. The list of failed member names can be accessed via `adapter.traits().reporter().failed_members()` after validation.
2341
2341
2342
2342
There are a few notes about using failed members adapter.
2343
2343
@@ -2374,7 +2374,7 @@ int main()
2374
2374
_["field4"](lt,5)
2375
2375
);
2376
2376
auto ret=v1.apply(ra1);
2377
-
assert(ret.success()); // DO NOT COUNT ON THIS because success() might be returned when validation failed (see below)
2377
+
assert(ret.success()); // DO NOT COUNT ON THIS because success() might be true even when validation failed (see below)
2378
2378
assert(members1.empty()); // members are empty for success validation
2379
2379
ra1.reset(); // do not forget to reset adapter before next use
0 commit comments