File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -314,6 +314,30 @@ UUID objects created with the ``Uuid`` class can use the following methods
314314 // * int < 0 if $uuid1 is less than $uuid4
315315 $uuid1->compare($uuid4); // e.g. int(4)
316316
317+ If you're working with different UUIDs format and want to validate them,
318+ you can use the ``$format `` parameter of the :method: `Symfony\\ Component\\ Uid\\ Uuid::isValid `
319+ method to specify the UUID format you're expecting::
320+
321+ use Symfony\Component\Uid\Uuid;
322+
323+ $isValid = Uuid::isValid('90067ce4-f083-47d2-a0f4-c47359de0f97', Uuid::FORMAT_RFC_4122); // accept only RFC 4122 UUIDs
324+ $isValid = Uuid::isValid('3aJ7CNpDMfXPZrCsn4Cgey', Uuid::FORMAT_BASE_32 | Uuid::FORMAT_BASE_58); // accept multiple formats
325+
326+ The following constants are available:
327+
328+ * ``Uuid::FORMAT_BINARY ``
329+ * ``Uuid::FORMAT_BASE_32 ``
330+ * ``Uuid::FORMAT_BASE_58 ``
331+ * ``Uuid::FORMAT_RFC_4122 ``
332+
333+ You can also use the ``Uuid::FORMAT_ALL `` constant to accept any UUID format.
334+ By default, only the RFC 4122 format is accepted.
335+
336+ .. versionadded :: 7.2
337+
338+ The ``$format `` parameter of the :method: `Symfony\\ Component\\ Uid\\ Uuid::isValid `
339+ method and the related constants were introduced in Symfony 7.2.
340+
317341Storing UUIDs in Databases
318342~~~~~~~~~~~~~~~~~~~~~~~~~~
319343
You can’t perform that action at this time.
0 commit comments