Repository navigation
feat: add opt-in strictPrefix option - #41
Conversation
|
Thanks @NspxMiguel, this is a really clean PR. It's small, focused, and follows the issue closely. What I checked:
A few small changes before I merge:
Optional, happy either way: the 64-character error says Thanks again, this is very close! |
createId and createSortableId accept strictPrefix. When true, the prefix must be 1-63 ASCII letters or digits; otherwise a TypeError names the first offending character. Default behavior is unchanged.
Make strict a required parameter so callers that forget it fail to compile instead of silently skipping the check. Cover an emoji prefix, show the full error text in the README, and report the prefix length in the 64-character error.
94a7e45 to
d4e2df7
Compare
|
Thanks for the careful review. Pushed: For #45 I'll pass |
Closes #35
Adds
strictPrefix?: booleantocreateIdandcreateSortableId. Whentrue, the prefix must match/^[A-Za-z0-9]{1,63}$/, otherwise aTypeErrornames the first offending character, e.g.prefid: prefix "us er" contains an invalid character " " at index 2.assertValidPrefix(src/internal/prefix.ts)npm run verifypasses; default behavior is unchanged