Skip to content

[Validator] Add Ulid constraint and validator #38322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

laurent35240
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #38152
License MIT

ULID constraint and validator as mentioned in ticket #38103
I checked for it ulid specifications https://github.com/ulid/spec

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thnks, almost good to me.

->addViolation();
}

if (\strlen($value) !== strspn($value, '0123456789ABCDEFGHJKMNPQRSTVWXYZabcdefghjkmnpqrstvwxyz')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

26 !== strspn([...]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to keep \strlen($value) otherwise a too short ULID but with only valid characters will have violations about being too short AND having invalid characters.
The violation about invalid characters would not be true in this case.

Let me know what you think about it

@laurent35240
Copy link
Contributor Author

Everything modified except one part which I think makes more sense how it is right now (cf comment in code review)

@fabpot
Copy link
Member

fabpot commented Sep 29, 2020

Thank you @laurent35240.

@fabpot fabpot merged commit e159dff into symfony:master Sep 29, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
@fabpot fabpot mentioned this pull request Oct 5, 2020
OskarStark added a commit to symfony/symfony-docs that referenced this pull request Oct 6, 2020
…ent35240)

This PR was merged into the 5.x branch.

Discussion
----------

[Validator] Add documentation for ULID validator

Resolves #14298

Related to feature PR symfony/symfony#38322

Commits
-------

b37ca01 [Validator] Add documention for ULID validator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add UuidValidator / UlidValidator
4 participants