-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.in
48 lines (39 loc) · 1.34 KB
/
README.in
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
46
47
48
## jvindicator
Trivial parameter validation functions intended for use in HTTP servlet
applications.
### Features
* Type-safe parameter validation.
* Written in pure Java 21.
* [OSGi](https://www.osgi.org/) ready.
* [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) ready.
* ISC license.
* High-coverage automated test suite.
### Usage
Use the `Vindicator` class to build a validator, and then call `check()`. After
calling `check()`, parameters can be inspected in a type-safe manner:
```
final var v =
Vindication.start();
final var p0 =
v.addRequiredParameter("u0", Vindication.integerUnsigned());
final var p1 =
v.addRequiredParameter("u1", Vindication.integerUnsignedLong());
final var p2 =
v.addRequiredParameter("s0", Vindication.integerSigned());
final var p3 =
v.addRequiredParameter("s1", Vindication.integerSignedLong());
final var p4 =
v.addRequiredParameter("i0", Vindication.integerBig());
v.check(Map.ofEntries(
Map.entry("u0", new String[]{"23"}),
Map.entry("u1", new String[]{"24"}),
Map.entry("s0", new String[]{"-23"}),
Map.entry("s1", new String[]{"-24"}),
Map.entry("i0", new String[]{"-4703919738795935661825"})
));
assertEquals(23, p0.get());
assertEquals(24L, p1.get());
assertEquals(-23, p2.get());
assertEquals(-24L, p3.get());
assertEquals(new BigInteger("-4703919738795935661825"), p4.get());
```