-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(concerto): fix bugs when id field has regex (#630)
Signed-off-by: Diana Lease <[email protected]>
- Loading branch information
1 parent
ac7b35a
commit 77d216f
Showing
10 changed files
with
161 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -30,7 +30,7 @@ const { Parser } = require('@accordproject/concerto-cto'); | |
|
||
describe('concerto-cli', () => { | ||
const models = [path.resolve(__dirname, 'models/dom.cto'),path.resolve(__dirname, 'models/money.cto')]; | ||
const offlineModels = [path.resolve(__dirname, 'models/contract.cto'),path.resolve(__dirname, 'models/dom.cto'),path.resolve(__dirname, 'models/money.cto')]; | ||
const offlineModels = [path.resolve(__dirname, 'models/contract.cto'),path.resolve(__dirname, 'models/dom.cto'),path.resolve(__dirname, 'models/money.cto'),path.resolve(__dirname, 'models/person.cto')]; | ||
const input1 = path.resolve(__dirname, 'data/input1.json'); | ||
const input2 = path.resolve(__dirname, 'data/input2.json'); | ||
const inputText1 = fs.readFileSync(input1, 'utf8'); | ||
|
@@ -641,5 +641,25 @@ describe('concerto-cli', () => { | |
obj.$class.should.equal('org.accordproject.cicero.dom.ContractTemplate'); | ||
Object.keys(obj).should.eql(['$class', 'metadata', 'content', 'id', '$identifier']); | ||
}); | ||
|
||
it('should generate an identified object with an identifier property with regex', async () => { | ||
const obj = await Commands.generate( | ||
offlineModels, | ||
'[email protected]', | ||
'sample', | ||
{ offline: true, optionalFields: true } | ||
); | ||
obj.ssn.should.match(/\d{3}-\d{2}-\d{4}/); | ||
}); | ||
|
||
it('should generate an identified object identified by a scalar', async () => { | ||
const obj = await Commands.generate( | ||
offlineModels, | ||
'[email protected]', | ||
'sample', | ||
{ offline: true, optionalFields: true } | ||
); | ||
(typeof obj.ssn).should.equal('string'); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
namespace [email protected] | ||
|
||
concept Person identified by ssn { | ||
o String name | ||
@description("Height (cm)") | ||
o Double height range=[0.0,] | ||
o DateTime dateOfBirth | ||
o String ssn regex=/\d{3}-\d{2}-\d{4}/ | ||
} | ||
|
||
scalar SSN extends String regex=/\d{3}-\d{2}-\d{4}/ | ||
|
||
concept Person2 identified by ssn { | ||
o String name | ||
@description("Height (cm)") | ||
o Double height range=[0.0,] | ||
o DateTime dateOfBirth | ||
o SSN ssn | ||
} |
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
Oops, something went wrong.