Skip to content

feat: add toBeUlid assertion and isUlid validation method#1726

Merged
nunomaduro merged 1 commit into
pestphp:5.xfrom
sonalidudhia:tobeulid-exception
Jun 11, 2026
Merged

feat: add toBeUlid assertion and isUlid validation method#1726
nunomaduro merged 1 commit into
pestphp:5.xfrom
sonalidudhia:tobeulid-exception

Conversation

@sonalidudhia

Copy link
Copy Markdown

What

Adds toBeUlid() (and not->toBeUlid()) expectation for validating
26-character Crockford Base32 strings (ULIDs).

Why

ULIDs are a common sortable UUID alternative used in Laravel, Symfony,
and standalone PHP projects. toBeUuid() already exists; this fills
the obvious gap.

How

  • Str::isUlid() added to Support/Str.php — pure regex, no deps
  • toBeUlid() added to Mixins/Expectation.php — mirrors toBeUuid() exactly
  • Test file mirrors toBeUuid.php structure

Notes

  • No new dependencies
  • PHP 8.3+, PHPUnit 13-compatible
  • Regex: /^[0-9A-HJKMNP-TV-Z]{26}$/ (strict uppercase, per Crockford spec)

@nunomaduro nunomaduro merged commit 774a340 into pestphp:5.x Jun 11, 2026
@nunomaduro

Copy link
Copy Markdown
Member

can you add this to docs?

@sonalidudhia

Copy link
Copy Markdown
Author

I have created this PR for docs - pestphp/docs#363
@nunomaduro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants