-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: regex for schemaVersion, issuerDid, credDefId, schemaId, schema…
…IssuerDid (#679) Signed-off-by: annelein <[email protected]>
- Loading branch information
Showing
10 changed files
with
70 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { credDefIdRegex, indyDidRegex, schemaIdRegex, schemaVersionRegex } from '../regex' | ||
|
||
describe('Valid Regular Expression', () => { | ||
const invalidTest = 'test' | ||
|
||
test('test for credDefIdRegex', async () => { | ||
const test = 'q7ATwTYbQDgiigVijUAej:3:CL:160971:1.0.0' | ||
expect(test).toMatch(credDefIdRegex) | ||
expect(credDefIdRegex.test(invalidTest)).toBeFalsy() | ||
}) | ||
|
||
test('test for indyDidRegex', async () => { | ||
const test = 'did:sov:q7ATwTYbQDgiigVijUAej' | ||
expect(test).toMatch(indyDidRegex) | ||
expect(indyDidRegex.test(invalidTest)).toBeFalsy | ||
}) | ||
|
||
test('test for schemaIdRegex', async () => { | ||
const test = 'q7ATwTYbQDgiigVijUAej:2:test:1.0' | ||
expect(test).toMatch(schemaIdRegex) | ||
expect(schemaIdRegex.test(invalidTest)).toBeFalsy | ||
}) | ||
|
||
test('test for schemaVersionRegex', async () => { | ||
const test = '1.0.0' | ||
expect(test).toMatch(schemaVersionRegex) | ||
expect(schemaVersionRegex.test(invalidTest)).toBeFalsy | ||
}) | ||
}) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const schemaIdRegex = /^[a-zA-Z0-9]{21,22}:2:.+:[0-9.]+$/ | ||
export const schemaVersionRegex = /^(\d+\.)?(\d+\.)?(\*|\d+)$/ | ||
export const credDefIdRegex = /^([a-zA-Z0-9]{21,22}):3:CL:(([1-9][0-9]*)|([a-zA-Z0-9]{21,22}:2:.+:[0-9.]+)):(.+)?$/ | ||
export const indyDidRegex = /^(did:sov:)?[a-zA-Z0-9]{21,22}$/ |