Skip to content

Commit 140f12a

Browse files
committed
Update README with more UUID examples
1 parent 6304ab0 commit 140f12a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,30 @@ This filter verifies a given string is a valid universally unique identifier.
158158

159159
The second parameter can be set to `true` to allow null values through without an error.
160160

161-
The third parameter determines which UUID version the value will be validated against. By default, the filter will succeed if the values matches version 1, 2, 3, 4, 5, 6, or 7
161+
The third parameter can be set to `true` to allow [Nil UUIDs](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.7) values through without an error.
162+
163+
The fourth parameter determines which UUID version the value will be validated against. By default, the filter will succeed if the values matches version 1, 2, 3, 4, 5, 6, or 7
162164

163165
```php
166+
// Filtering an UUID string
164167
$value = '1a42403c-a29d-11ef-b864-0242ac120002';
165168
$filtered = \TraderInteractive\Filter\UuidFilter::filter($value);
166169
assert($value === $filtered);
170+
171+
// Filtering null values
172+
$value = null;
173+
$filtered = \TraderInteractive\Filter\UuidFilter::filter($value, true);
174+
assert(null === $filtered);
175+
176+
// Filtering a nil UUID
177+
$value = '00000000-0000-0000-0000-000000000000';
178+
$filtered = \TraderInteractive\Filter\UuidFilter::filter($value, false, true);
179+
assert($value === $filtered);
180+
181+
// Filtering for only UUID v4
182+
$value = '1a42403c-a29d-41ef-b864-0242ac120002';
183+
$filtered = \TraderInteractive\Filter\UuidFilter::filter($value, false, false, [4]);
184+
assert($value === $filtered);
167185
```
168186

169187
#### XmlFilter::filter

0 commit comments

Comments
 (0)