# Validation and Constraints

Site [llms.txt](/gatherers4j/llms.txt)

---

Functions that enforce conditions on the stream


### Gatherers

| Function | Description |
|---|---|
| [ensureOrdered()](https://tginsberg.github.io/gatherers4j/gatherers/validation-and-constraints/ensureordered/index.md) | Ensure that the `Comparable` elements in the input stream are in the order specified, and fail exceptionally if they are not. |
| [ensureOrderedBy()](https://tginsberg.github.io/gatherers4j/gatherers/validation-and-constraints/ensureorderedby/index.md) | Ensure that the elements in the input stream are in the order specified, as measured by the given `Comparator`, and fail exceptionally if they are not. |
| [ensureSize()](https://tginsberg.github.io/gatherers4j/gatherers/validation-and-constraints/ensuresize/index.md) | Ensure the input stream is the proper `length` as specified by `size`. |

---

Section pages:

- [ensureOrdered()](/gatherers4j/gatherers/validation-and-constraints/ensureordered/): Ensure that the `Comparable` elements in the input stream are in the order specified, and fail exceptionally if they are not.
- [ensureOrderedBy()](/gatherers4j/gatherers/validation-and-constraints/ensureorderedby/): Ensure that the elements in the input stream are in the order specified, as measured by the given `Comparator`, and fail exceptionally if they are not.
- [ensureSize()](/gatherers4j/gatherers/validation-and-constraints/ensuresize/): Ensure the input stream is the proper `length` as specified by `size`.
