Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/fo/vn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ describe('fo/vn', () => {
expect(result.isValid && result.compact).toEqual('623857');
});

it('validate:FO384941', () => {
const result = validate('FO384941');

expect(result.isValid && result.compact).toEqual('384941');
});

test.each(['623857', '33 28 28', '563.609'])('validate:%s', value => {
const result = validate(value);

Expand Down
2 changes: 1 addition & 1 deletion src/fo/vn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { strings } from '../util';
import { Validator, ValidateReturn } from '../types';

function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
return strings.cleanUnicode(input, ' -.');
return strings.cleanUnicode(input, ' -.', 'FO');
}
Comment on lines 18 to 20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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');
}


// const validRe = /^[PCGQV]{1}00[A-Z0-9]{8}$/;
Expand Down
Loading