Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Update to simplify regex and add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Jun 6, 2023
1 parent 09c20f3 commit c77427e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion elements/lisk-validator/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const isHexString = (data: unknown): boolean => {
return false;
}

return data === '' || /^([0-9a-fA-F]{2})+$/i.test(data);
return data === '' || /^([0-9a-f]{2})+$/i.test(data);
};

export const isEncryptedPassphrase = (data: string): boolean => {
Expand Down
5 changes: 4 additions & 1 deletion elements/lisk-validator/test/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ describe('validation', () => {

describe('#isHexString', () => {
it('should return true when valid hex was provided', () => {
return expect(
expect(
isHexString('215b667a32a5cd51a94c9c2046c11fffb08c65748febec099451e3b164452b'),
).toBeTrue();
expect(
isHexString('215B667A32a5cd51A94c9c2046c11fffb08c65748febec099451e3b164452B'),
).toBeTrue();
});

it('should return false when number was provided', () => {
Expand Down

0 comments on commit c77427e

Please sign in to comment.