Skip to content

[Validator] UlidValidator should accept RFC4122 formatted ULID #51540

Closed
@kaznovac

Description

@kaznovac

Symfony version(s) affected

6.x

Description

Validation of Ulid string got by $ulid->toRfc4122() (e.g. 018a5293-72b6-c9b0-4361-7ce3d6c2e4ef) creates validation violation.

there is strict string length validation here and it fails (the rfc4122 string is 36 chars long)

if (26 !== \strlen($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(26 > \strlen($value) ? Ulid::TOO_SHORT_ERROR : Ulid::TOO_LONG_ERROR)
->addViolation();
return;
}

How to reproduce

  • create new Ulid
  • get it's rfc4122 formated string value
  • try to validate it with UlidValidator

Possible Solution

allow other ulid formats in validator

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions