BB-888: feat: add built-in identifier validation with admin dropdown#1273
Open
atharvsp02 wants to merge 1 commit into
Open
BB-888: feat: add built-in identifier validation with admin dropdown#1273atharvsp02 wants to merge 1 commit into
atharvsp02 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Ticket: BB-888
BookBrainz validates identifiers using only regex, which cannot catch mathematical errors like invalid ISBN checksums. A typo like 9780306406150 (wrong check digit) passes regex validation and gets saved to the database.
Solution
Added support for built-in JavaScript validation functions that run alongside regex:
validation_functioncolumn inidentifier_typetable maps to named JS functionsAdding support for new identifier checksums (like ISSN etc.) just requires writing a validation function in
identifier-validators.tsand registering it. Once deployed, admins can assign it to any identifier type through the UI without further code changes.Areas of Impact
identifier-validators.ts- ISBN checksum logic and validator registrycommon.ts- Calls built-in validator before falling back to regexidentifier-type.tsx- Admin dropdown for validation functiontypeUtils.tsx, types.ts` - Added validationFunction propertytypeRouteUtils.ts- Server side save/load of new fieldidentifier-types-tree.tsx- Display validation function in type listingbookbrainz.sql- Added column to base schemasql/migrations/2026-03-23/- Migration for new columnScreenshots
Before
After
AI usage
If you did use AI:
Action
Run SQL migration
sql/migrations/2026-03-23/up.sql