fix(fo/vn): strip the FO prefix in compact#161
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the Faroe Islands V-number validation logic to correctly handle inputs prefixed with 'FO'. By stripping this prefix during the cleaning phase, the validator ensures that such inputs are processed correctly rather than failing due to invalid length, aligning the implementation with upstream standards. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the validation logic for FO numbers by stripping the 'FO' prefix in the clean function and adds a corresponding test case. The reviewer suggested simplifying the clean function by utilizing the third parameter of cleanUnicode to strip the prefix, which also avoids using the deprecated substr method.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function clean(input: string): ReturnType<typeof strings.cleanUnicode> { | ||
| return strings.cleanUnicode(input, ' -.'); | ||
| const [value, err] = strings.cleanUnicode(input, ' -.'); | ||
|
|
||
| if (err !== null) { | ||
| return [value, err]; | ||
| } | ||
| if (value.startsWith('FO')) { | ||
| return [value.substr(2), null]; | ||
| } | ||
|
|
||
| return [value, null]; | ||
| } |
There was a problem hiding this comment.
The cleanUnicode utility function already supports a third parameter stripPrefix to automatically strip a prefix (or list of prefixes) after cleaning and converting to uppercase.
Using this built-in parameter simplifies the implementation and avoids the use of the deprecated String.prototype.substr() method.
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
return strings.cleanUnicode(input, ' -.', 'FO');
}0fa99c0 to
d88a600
Compare
|
Thanks — refactored |
Faroe Islands V-numbers are frequently written with the
FOcountry prefix (e.g.FO384941).compactdoes not remove it, so the value is 8 characters and validation fails withInvalidLength.Strip a leading
FOinclean, following the same approach already used for theBEprefix inbe/vatand matching the upstream python-stdnum reference (validate('FO384941')→'384941').