Skip to content

Commit 31c867e

Browse files
Fix max_depth docs to clarify level-based counting with examples
1 parent 091ba3b commit 31c867e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/api-guide/fields.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ A field class that validates a list of objects.
477477
* `allow_empty` - Designates if empty lists are allowed.
478478
* `min_length` - Validates that the list contains no fewer than this number of elements.
479479
* `max_length` - Validates that the list contains no more than this number of elements.
480-
* `max_depth` - Validates that nesting depth does not exceed this value. This applies to both the field schema depth and the raw input data depth. Depth of 0 permits the field itself but no nesting. Defaults to `None` (no limit).
480+
* `max_depth` - Validates that nesting depth does not exceed this value. This applies to both the field schema depth and the raw input data depth. A value of 1 permits a flat structure (e.g., `[1, 2, 3]`) but rejects nested data (e.g., `[[1, 2]]`). Defaults to `None` (no limit).
481481

482482
For example, to validate a list of integers you might use something like the following:
483483

@@ -500,7 +500,7 @@ A field class that validates a dictionary of objects. The keys in `DictField` ar
500500

501501
* `child` - A field instance that should be used for validating the values in the dictionary. If this argument is not provided then values in the mapping will not be validated.
502502
* `allow_empty` - Designates if empty dictionaries are allowed.
503-
* `max_depth` - Validates that nesting depth does not exceed this value. This applies to both the field schema depth and the raw input data depth. Depth of 0 permits the field itself but no nesting. Defaults to `None` (no limit).
503+
* `max_depth` - Validates that nesting depth does not exceed this value. This applies to both the field schema depth and the raw input data depth. A value of 1 permits a flat structure (e.g., `{"a": 1}`) but rejects nested data (e.g., `{"a": {"b": 1}}`). Defaults to `None` (no limit).
504504

505505
For example, to create a field that validates a mapping of strings to strings, you would write something like this:
506506

0 commit comments

Comments
 (0)