Skip to content

Commit

Permalink
Fix uninitialised variable, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanpenman committed Feb 8, 2025
1 parent caa3ef0 commit 7d59abf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ Valijson has a notion of strong and weak typing. By default, strong typing is us
Validator validator;
```

This is equivalent to:

```cpp
Validator validator(Validator::kStrongTypes);
```
This validator will not attempt to cast between types to satisfy a schema. So the string `"23"` will not be parsed as a number.
Alternatively, weak typing can be used:
Expand All @@ -87,6 +93,22 @@ Validator validator(Validator::kWeakTypes);

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.

### Strict vs Permissive Date/Time Formats

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.

Valijson can be configured to allow ambiguous date/time strings.

```cpp
Validator validator(Validator::kStrongTypes, Validator::kPermissiveDateTime);
```
The default is strict date/time validation, which is equivalent to:
```cpp
Validator validator(Validator::kStrongTypes, Validator::kStrictDateTime);
```

## Regular Expression Engine

When enforcing a 'pattern' property, a regular expression engine is used. By default, the default regular expression (`DefaultRegexEngine`) uses `std::regex`.
Expand Down
4 changes: 3 additions & 1 deletion include/valijson/validator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class ValidatorT
* @brief Construct a Validator that uses strong type checking by default
*/
ValidatorT()
: strictTypes(true) { }
: strictTypes(true)
, strictDateTime(true)
{ }

/**
* @brief Construct a Validator using a specific type checking mode
Expand Down

0 comments on commit 7d59abf

Please sign in to comment.