Skip to content

Commit 61ff8c9

Browse files
committed
Update README.md
1 parent 0a6837a commit 61ff8c9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,35 @@ A typical approach for implementing complex data validation is writing nested *i
88

99
`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 with taking into account the user's locale.
1010

11+
Minimal example:
12+
13+
```cpp
14+
// define validator
15+
auto v1=validator(
16+
_[key1][key1_1][key1_2](gt,100),
17+
_[key2][key2_1](value(ne,"UNKNOWN") ^AND^ size(lte,32))
18+
);
19+
20+
// validate objects
21+
Class1 obj1;
22+
Class2 obj2;
23+
24+
validate(obj1,v1);
25+
validate(obj2,v1);
26+
```
27+
1128
## Introduction
1229
1330
*cpp-validator* is a modern C++ header-only library for validation of variables, objects and containers.
1431
1532
The library can be used to validate:
1633
- plain variables;
17-
- properties of objects, where a property can be accessed either as object's variable or object's getter method;
34+
- properties of objects, where a property can be accessed either as object's variable or object's method;
1835
- contents and properties of containers;
19-
- nested containers and objects.
36+
- nested containers and objects;
37+
- heterogeneous containers such as pairs and tuples;
38+
- trees;
39+
- transformed values or results of evaluations.
2040
2141
Basic usage of the library includes two steps:
2242

0 commit comments

Comments
 (0)