File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
159159Validator::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)
167168Validator::isInt()->coerce()->validate(''); // null (if not required)
You can’t perform that action at this time.
0 commit comments