Skip to content

[Feature Request] Add support for ULID as a well_known validation rule #90

@joldf

Description

@joldf

Feature description:

Support for ULID as a well_known validation rule.

Problem it solves or use case:

ULID aims to be a unique identifier that can be generated on independent machines, much like UUID. However, the first component is generated from the timestamp (and the second half is meant to be monotonic for a given timestamp on a given generator, although this is not often followed in practice). This has the effect that it is better suited to use cases where ordering helps with performance, particularly database indices.

https://github.com/ulid/spec

It is possible to use the existing regex validation facility, but doing this separately to ever ULID field is quite redundant and noisy. Additionally, marking a field as ULID carries some semantic information (e.g. for generated documentation). Basically: the standard arguments for adding something as a well-known type.

Proposed implementation or solution:

Add ULID to the well_known oneof, and its implementation could be the following regex or equivalent (this is Python syntax):

[0-7][0-9A-HJKMNP-TV-Z]{25}

Alternatively, for a case insensitive implementation (this is what the ULID spec recommends but is probably less useful in a data interchange format, especially to optimise use as a database index):

[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}

Contribution:

Unfortunately I can't contribute an implementation, but would be happy to help with testing.

Examples or references:

Similar request for old protoc-gen-validate (issue 278)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions