Skip to content

Commit f000abf

Browse files
committed
docs(llms): enhance pipeline order example with detailed transformation steps and clarifications
1 parent 0605b5a commit f000abf

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

llms.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,14 @@ oneOf(array $values, ?string $message = null): static // Deprecated alias for in
155155

156156
## Quick Examples
157157
```php
158-
// Pipeline order: pipe -> nullifyEmpty -> required (flag enforced after pipeline) -> date validation -> transform
158+
// Pipeline order demonstration: shows value transformation at each step
159159
Validator::isString()
160-
->pipe('trim') // String operations (preserves type)
161-
->nullifyEmpty()
162-
->required()
163-
->date('Y-m-d')
164-
->transform(fn($s) => DateTime::createFromFormat('Y-m-d', $s)); // String → DateTime
160+
->pipe('trim') // Transformation: " \n " → "" (preserves string type, skips null)
161+
->nullifyEmpty() // Transformation: "" → null (converts empty string/array to null)
162+
->required() // Validation flag: enforced after pipeline, throws if value is null
163+
->date('Y-m-d') // Validation: checks format Y-m-d (skips null, but required() ensures non-null)
164+
->transform(fn($s) => DateTime::createFromFormat('Y-m-d', $s)); // Transformation: String → DateTime (receives validated string)
165+
// With valid input "2024-01-15": "2024-01-15" → trim → "2024-01-15" → nullifyEmpty (no-op) → date validation → transform receives "2024-01-15" → DateTime
165166

166167
// Form-safe coercion: '' -> null (not 0/false)
167168
Validator::isInt()->coerce()->validate(''); // null (if not required)

0 commit comments

Comments
 (0)