Skip to content

Commit 7d59abf

Browse files
committed
Fix uninitialised variable, update README
1 parent caa3ef0 commit 7d59abf

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ Valijson has a notion of strong and weak typing. By default, strong typing is us
7777
Validator validator;
7878
```
7979

80+
This is equivalent to:
81+
82+
```cpp
83+
Validator validator(Validator::kStrongTypes);
84+
```
85+
8086
This validator will not attempt to cast between types to satisfy a schema. So the string `"23"` will not be parsed as a number.
8187
8288
Alternatively, weak typing can be used:
@@ -87,6 +93,22 @@ Validator validator(Validator::kWeakTypes);
8793

8894
This will create a validator that will attempt to cast values to satisfy a schema. The original motivation for this was to support the Boost Property Tree library, which can parse JSON, but stores values as strings.
8995

96+
### Strict vs Permissive Date/Time Formats
97+
98+
JSON Schema supports validation of certain types using the `format` keyword. Supported formats include `time`, `date`, and `date-time`. When `date-time` is used, the input is validated according to [RFC 3999](./doc/specifications/rfc3339-timestamps.txt). By default, RFC 3999 requires that all date/time strings are unambiguous - i.e. are defined in terms of a local time zone. This is controlled by the `Z` suffix (for UTC) or a `+01:00` style modifier.
99+
100+
Valijson can be configured to allow ambiguous date/time strings.
101+
102+
```cpp
103+
Validator validator(Validator::kStrongTypes, Validator::kPermissiveDateTime);
104+
```
105+
106+
The default is strict date/time validation, which is equivalent to:
107+
108+
```cpp
109+
Validator validator(Validator::kStrongTypes, Validator::kStrictDateTime);
110+
```
111+
90112
## Regular Expression Engine
91113

92114
When enforcing a 'pattern' property, a regular expression engine is used. By default, the default regular expression (`DefaultRegexEngine`) uses `std::regex`.

include/valijson/validator.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class ValidatorT
3535
* @brief Construct a Validator that uses strong type checking by default
3636
*/
3737
ValidatorT()
38-
: strictTypes(true) { }
38+
: strictTypes(true)
39+
, strictDateTime(true)
40+
{ }
3941

4042
/**
4143
* @brief Construct a Validator using a specific type checking mode

0 commit comments

Comments
 (0)