Skip to content

Inconsistent results between fromString and isValid methods. #531

Open
@rogervila

Description

@rogervila

Description

When creating a UUID instance from a string without dashes (ie: 00000000000000000000000000000000) it works, but when receiving the same string to validate if it's a valid UUID it fails, which is inconsistent.

The library should not be able to create a UUID for a string that is not valid.

Steps to reproduce

  1. Create a UUID from a 00000000000000000000000000000000 string. It returns a UUID instance
  2. validate 00000000000000000000000000000000 using the isValid function. It returns false.

Expected behavior

The library should not be able to create a UUID for a string that is not valid.

Screenshots or output

Input and output from Laravel tinker:

> \Ramsey\Uuid\Uuid::fromString('00000000000000000000000000000000')
= Ramsey\Uuid\Rfc4122\NilUuid {#5021
    uuid: "00000000-0000-0000-0000-000000000000",
  }

> \Ramsey\Uuid\Uuid::isValid('00000000000000000000000000000000')
= false

Environment details

  • version of this package: 4.7.5
  • PHP version: 8.2.14
  • OS: macOS 13.6.1

Additional context

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions