Skip to content

Commit 9e56dec

Browse files
committed
Optimize regex pattern
1 parent 9b3168b commit 9e56dec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ulid/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ def __get_pydantic_core_schema__(cls, source: Any, handler: GetCoreSchemaHandler
296296
core_schema.union_schema([
297297
core_schema.is_instance_schema(ULID),
298298
core_schema.no_info_plain_validator_function(ULID),
299-
core_schema.str_schema(pattern=r"[01234567][0123456789ABCDEFGHJKMNPQRSTVWXYZ]{25}", min_length=26, max_length=26),
299+
core_schema.str_schema(
300+
pattern=rf"[0-7][{base32.ENCODE}]{{25}}",
301+
min_length=26,
302+
max_length=26,
303+
),
300304
core_schema.bytes_schema(min_length=16, max_length=16),
301305
]),
302306
serialization=core_schema.to_string_ser_schema(

0 commit comments

Comments
 (0)