Skip to content

BB-650: feat: Improve ISBN/Barcode detection for spaced, hyphenated input and add confirmation checkbox#1221

Open
atharvsp02 wants to merge 1 commit intometabrainz:masterfrom
atharvsp02:BB-650
Open

BB-650: feat: Improve ISBN/Barcode detection for spaced, hyphenated input and add confirmation checkbox#1221
atharvsp02 wants to merge 1 commit intometabrainz:masterfrom
atharvsp02:BB-650

Conversation

@atharvsp02
Copy link
Contributor

@atharvsp02 atharvsp02 commented Feb 1, 2026

Problem

Ticket: BB-650

ISBN and Barcode identifiers with spaces and hypens (e.g. 9 788205 174238) were not being detected or validated correctly. Users had to manually remove spaces before entering identifiers. Additionally, there was no way to submit unusual identifier values that don't match the expected regex format.

Solution

  • Added auto-detection for ISBN-10, ISBN-13, and Barcode formats even with spaces and hyphens in input
  • Normalized identifier values before validation to handle formatted inputs
  • Added confirmation checkbox that allows users to submit unusual identifier values by manually confirming them

Areas of Impact

Entity Editor(Identifier Editor):

  • Identifier input now accepts formatted values with spaces and hyphens
  • Auto-detection extended to handle spaced or hyphenated ISBN and Barcode values
  • Confirmation checkbox appears for invalid/unusual values

Unified Form (Cover Tab):

  • ISBN field accepts formatted input
  • Confirmation checkbox for unusual ISBN values

Screenshots

Before(Spaced and Unusual values)

image

After(Spaced and Unusual values)

image

Let me know if you have any suggestions or changes you’d like me to make.

@atharvsp02 atharvsp02 changed the title BB-650: feat: Improve ISBN/Barcode detection with spaced and hyphenated input and confirmation checkbox for unusual values BB-650: feat: Improve ISBN/Barcode detection for spaced, hyphenated input and add confirmation checkbox Feb 1, 2026
Copy link
Member

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

I think this is on the right track, but there are a few things I think could be changed. Generally, I think you should be trying to improve the existing mechanisms where possible rather than adding new methods.

<FormCheck
checked={confirmed}
id={`identifier-confirm-${index}`}
label={`This doesn't look like a valid ${selectedIdentifierType}. Are you sure this is correct?`}
Copy link
Member

Choose a reason for hiding this comment

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

While this makes sense, I think the wording is strange for a checkbox which is usually an action.
I think either we show a bit of helptext above and change the checkbox label to "confirm" sort of text, or we rephrase the whole thing like "☑️ Confirm this invalid ISBN-13 (I know what I'm doing)"
Like this maybe?
Image

<Row>
<Col>
Preview Link:
<IdentifierLink typeId={typeValue} value={valueValue}/>
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about formatting ISBNs like so in the preview?

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that is perfect
I have implemented the preview to display the ISBN with hyphens using the isbn3 library. I chose the library because manually implementing hyphenation looks difficult. Do you agree with this approach?

</Col>
</Row>
)}
{valueValue && typeValue && !validateIdentifierValue(valueValue, typeValue, typeOptions) && (
Copy link
Member

Choose a reason for hiding this comment

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

This should be limited to certain types only.
ISBN-10, ISBN-13 and Barcode

value = result[1];
let value = collapseWhiteSpaces(event.target.value);
const detectedType = detectIdentifierType(value);
let guessedType = null;
Copy link
Member

Choose a reason for hiding this comment

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

Would this work?

Suggested change
let guessedType = null;
const guessedType = types.find((type) => type.label === detectedType);

Then checking if there is a match, otherwise the else block on line 182

const result = new RegExp(guessedType.detectionRegex).exec(value);
value = result[1];
let value = collapseWhiteSpaces(event.target.value);
const detectedType = detectIdentifierType(value);
Copy link
Member

Choose a reason for hiding this comment

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

Not a big fan of this new detectIdentifierType, why not improve the existing regexps that are used in guessIdentifierType instead?
Those are stored in the database, and could be improved based on the regexps here
https://github.com/metabrainz/bookbrainz-site/pull/1221/changes#diff-8841d7e2bffbb263a4a64fda61e9c9b35b28ee141e63e6b9e1b34063fd0a5c5fL58-L61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments