|
4 | 4 |
|
5 | 5 | **Chevere Parameter** is a library for building dynamic, validated parameters with type-safe rules and schema introspection. It enables you to define rich validation constraints for any PHP type, from simple scalars to deeply nested arrays, using either helper functions or attributes, eliminating boilerplate validation logic across your codebase. |
6 | 6 |
|
7 | | -See [chevere/action](https://github.com/chevere/action) for our object-oriented convention around this package. |
| 7 | +* **[chevere/action](https://chevere.org/packages/action)**: Implements the action design pattern for encapsulating business logic, utilizing this package for comprehensive parameter validation. |
| 8 | +* **[chevere/router](https://chevere.org/packages/router)**: Offers powerful routing with built-in parameter validation for handling HTTP requests and responses. |
| 9 | +* **[chevere/sql2p](https://chevere.org/packages/sql2p)**: Transforms SQL queries into parameter definitions, enabling automated validation of database inputs and outputs. |
8 | 10 |
|
9 | 11 | ## Installing |
10 | 12 |
|
@@ -195,20 +197,19 @@ Common methods available on all parameters: |
195 | 197 |
|
196 | 198 | ```php |
197 | 199 | $parameter->withDescription('A human-readable label'); |
198 | | -$parameter->withIsSensitive(); // marks value as sensitive (omitted from error messages) |
| 200 | +$parameter->withIsSensitive(true); // marks value as sensitive (omitted from error messages) |
| 201 | +$parameter->withDefault($defaultValue); // sets a default value used when the parameter is optional and not provided |
199 | 202 | ``` |
200 | 203 |
|
201 | 204 | Methods specific to each parameter type: |
202 | 205 |
|
203 | | -| Parameter | Immutable methods | |
204 | | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | |
205 | | -| `IntParameter` | `withMin`, `withMax`, `withAccept`, `withReject`, `withDefault` | |
206 | | -| `FloatParameter` | `withMin`, `withMax`, `withAccept`, `withReject`, `withDefault` | |
207 | | -| `StringParameter` | `withRegex`, `withDefault` | |
208 | | -| `BoolParameter` | `withDefault` | |
209 | | -| `ArrayParameter` | `withRequired`, `withOptional`, `withModify`, `withMakeOptional`, `withMakeRequired`, `without`, `withOptionalMinimum` | |
210 | | -| `ObjectParameter` | `withClassName` | |
211 | | -| `IterableParameter` | `withKey`, `withValue` | |
| 206 | +| Parameter | Immutable methods | |
| 207 | +| ----------------- | ---------------------------------------------------------------------------------------------------------------------- | |
| 208 | +| `IntParameter` | `withMin`, `withMax`, `withAccept`, `withReject` | |
| 209 | +| `FloatParameter` | `withMin`, `withMax`, `withAccept`, `withReject` | |
| 210 | +| `StringParameter` | `withRegex` | |
| 211 | +| `ArrayParameter` | `withRequired`, `withOptional`, `withModify`, `withMakeOptional`, `withMakeRequired`, `without`, `withOptionalMinimum` | |
| 212 | +| `ObjectParameter` | `withClassName`, | |
212 | 213 |
|
213 | 214 | ### Schema introspection |
214 | 215 |
|
|
0 commit comments