Skip to content

Commit 3af015a

Browse files
committed
docs: Extend readme with info about strict mode
1 parent b1cd45b commit 3af015a

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
[![Latest Stable Version](https://poser.pugx.org/justinrainbow/json-schema/v/stable)](https://packagist.org/packages/justinrainbow/json-schema)
55
[![Total Downloads](https://poser.pugx.org/justinrainbow/json-schema/downloads)](https://packagist.org/packages/justinrainbow/json-schema/stats)
66

7-
A PHP Implementation for validating `JSON` Structures against a given `Schema` with support for `Schemas` of Draft-3 or Draft-4. Features of newer Drafts might not be supported. See [Table of All Versions of Everything](https://json-schema.org/specification-links.html#table-of-all-versions-of-everything) to get an overview of all existing Drafts.
7+
A PHP Implementation for validating `JSON` Structures against a given `Schema` with support for `Schemas` of Draft-3,
8+
Draft-4 or Draft-6.
9+
10+
Features of newer Drafts might not be supported. See [Table of All Versions of Everything](https://json-schema.org/specification-links.html#table-of-all-versions-of-everything) to get an overview
11+
of all existing Drafts.
12+
813

914
See [json-schema](http://json-schema.org/) for more details.
1015

@@ -187,24 +192,25 @@ A number of flags are available to alter the behavior of the validator. These ca
187192
third argument to `Validator::validate()`, or can be provided as the third argument to
188193
`Factory::__construct()` if you wish to persist them across multiple `validate()` calls.
189194

190-
| Flag | Description |
191-
|------|-------------|
192-
| `Constraint::CHECK_MODE_NORMAL` | Validate in 'normal' mode - this is the default |
193-
| `Constraint::CHECK_MODE_TYPE_CAST` | Enable fuzzy type checking for associative arrays and objects |
194-
| `Constraint::CHECK_MODE_COERCE_TYPES` | Convert data types to match the schema where possible |
195-
| `Constraint::CHECK_MODE_EARLY_COERCE` | Apply type coercion as soon as possible |
196-
| `Constraint::CHECK_MODE_APPLY_DEFAULTS` | Apply default values from the schema if not set |
197-
| `Constraint::CHECK_MODE_ONLY_REQUIRED_DEFAULTS` | When applying defaults, only set values that are required |
198-
| `Constraint::CHECK_MODE_EXCEPTIONS` | Throw an exception immediately if validation fails |
199-
| `Constraint::CHECK_MODE_DISABLE_FORMAT` | Do not validate "format" constraints |
200-
| `Constraint::CHECK_MODE_VALIDATE_SCHEMA` | Validate the schema as well as the provided document |
201-
202-
Please note that using `CHECK_MODE_COERCE_TYPES` or `CHECK_MODE_APPLY_DEFAULTS` will modify your
195+
| Flag | Description |
196+
|-------------------------------------------------|-----------------------------------------------------------------|
197+
| `Constraint::CHECK_MODE_NORMAL` | Validate in 'normal' mode - this is the default |
198+
| `Constraint::CHECK_MODE_TYPE_CAST` | Enable fuzzy type checking for associative arrays and objects |
199+
| `Constraint::CHECK_MODE_COERCE_TYPES` [^1] [^2] | Convert data types to match the schema where possible |
200+
| `Constraint::CHECK_MODE_EARLY_COERCE` [^2] | Apply type coercion as soon as possible |
201+
| `Constraint::CHECK_MODE_APPLY_DEFAULTS` [^1] | Apply default values from the schema if not set |
202+
| `Constraint::CHECK_MODE_ONLY_REQUIRED_DEFAULTS` | When applying defaults, only set values that are required |
203+
| `Constraint::CHECK_MODE_EXCEPTIONS` | Throw an exception immediately if validation fails |
204+
| `Constraint::CHECK_MODE_DISABLE_FORMAT` | Do not validate "format" constraints |
205+
| `Constraint::CHECK_MODE_VALIDATE_SCHEMA` | Validate the schema as well as the provided document |
206+
| `Constraint::CHECK_MODE_STRICT` [^3] | Validate the scheme using strict mode using the specified draft |
207+
208+
[^1]: Please note that using `CHECK_MODE_COERCE_TYPES` or `CHECK_MODE_APPLY_DEFAULTS` will modify your
203209
original data.
204-
205-
`CHECK_MODE_EARLY_COERCE` has no effect unless used in combination with `CHECK_MODE_COERCE_TYPES`. If
210+
[^2]: `CHECK_MODE_EARLY_COERCE` has no effect unless used in combination with `CHECK_MODE_COERCE_TYPES`. If
206211
enabled, the validator will use (and coerce) the first compatible type it encounters, even if the
207212
schema defines another type that matches directly and does not require coercion.
213+
[^3]: `CHECK_MODE_STRICT` only can be used for Draft-6 at this point.
208214

209215
## Running the tests
210216

0 commit comments

Comments
 (0)